<!DOCTYPE html>
<!-- saved from url=(0043)https://segmentfault.com/a/1190000039073805 -->
<html lang="zh-CN" data-react-helmet="lang"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否</title>
    
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <meta httpequiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="alexaVerifyID" content="LkzCRJ7rPEUwt6fVey2vhxiw1vQ">
    <meta name="apple-itunes-app" content="app-id=958101793, app-argument=">
    <meta property="qc:admins" content="15317273575564615446375">
    <meta name="msapplication-TileColor" content="#009a61">
    <meta name="baidu_union_verify" content="bcf7fd80dca60d53d46d5b46e1b990ca">
    <meta name="sogou_site_verification" content="MKVKCoIjwL">
    <meta name="360-site-verification" content="737314c9bf48873a1a0a22295203d9d1">
    <meta rel="apple-touch-icon" href="https://cdn.segmentfault.com/r-8b3ead20/touch-icon.png">
    <meta name="msapplication-square150x150logo" content="https://cdn.segmentfault.com/r-8b3ead20/touch-icon.png">
    <link rel="shortcut icon" type="image/x-icon" href="https://cdn.segmentfault.com/r-8b3ead20/favicon.ico">
    <link rel="search" type="application/opensearchdescription+xml" href="https://segmentfault.com/opensearch.xml" title="SegmentFault">
    <link rel="alternate" type="application/atom+xml" href="https://segmentfault.com/feeds/questions" title="SegmentFault 最新问题">
    <link rel="alternate" type="application/atom+xml" href="https://segmentfault.com/feeds/blogs" title="SegmentFault 最新文章">
    <link rel="stylesheet" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/umi.css">
    <script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/osd.js.下载"></script><script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f.txt"></script><script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(1).txt" id="google_shimpl"></script><script async="" defer="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(2).txt"></script><script async="" defer="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/fl.js.下载"></script><script async="" defer="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/spc.php"></script><script async="" defer="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/spcjs.php"></script><script type="text/javascript" async="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/analytics.js.下载"></script><script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/hm.js.下载"></script><script>
      window.routerBase = "/";
    </script>
    <script>
      window.publicPath =
        window.resourceBaseUrl || "https://cdn.segmentfault.com/r-8b3ead20/";
    </script>
    <script>
      //! umi version: 3.3.9
    </script>
    <script>
      var _hmt = _hmt || [];
    </script>
    <script>
      (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?e23800c454aa573c0ccb16b52665ac26";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
  <meta data-react-helmet="true" name="keywords" content="mysql,java,quartz,springboot"><meta data-react-helmet="true" name="description" content="Springboot整合quartz,实现动态定时任务的加载，不需要重启程序，就可以堆定时任务进行添加，停止，删除，重启等一系列操作，通过mysql数据库对定时任务进行配置。"><meta data-react-helmet="true" name="userId" value="" id="SFUserId"><meta data-react-helmet="true" name="userRank" value="" id="SFUserRank"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="twitter:image" content="https://cdn.segmentfault.com/r-8b3ead20/touch-icon.png"><meta data-react-helmet="true" name="twitter:site" content="@segment_fault"><meta data-react-helmet="true" name="twitter:creator" content="@segmentfault"><meta data-react-helmet="true" name="twitter:title" content="Springboot整合quartz实现定时任务的动态加载"><meta data-react-helmet="true" name="og:type" content="article"><meta data-react-helmet="true" name="og:image" content="https://cdn.segmentfault.com/r-8b3ead20/touch-icon.png"><meta data-react-helmet="true" name="og:title" content="Springboot整合quartz实现定时任务的动态加载"><meta data-react-helmet="true" name="msvalidate.01" content="2C018C53297C8388F3E7052F5E9CA6AF"><link rel="stylesheet" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/layouts__index_p__Live__Add_p__Video__Add_p__Write.chunk.css">
<link rel="stylesheet" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/layouts__index.chunk.css">
<link rel="stylesheet" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/p__ArticleDetail.chunk.css">
<script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/js" async=""></script><style>#__vconsole {
  --VC-BG-0: #ededed;
  --VC-BG-1: #f7f7f7;
  --VC-BG-2: #fff;
  --VC-BG-3: #f7f7f7;
  --VC-BG-4: #4c4c4c;
  --VC-BG-5: #fff;
  --VC-FG-0: rgba(0, 0, 0, 0.9);
  --VC-FG-HALF: rgba(0, 0, 0, 0.9);
  --VC-FG-1: rgba(0, 0, 0, 0.5);
  --VC-FG-2: rgba(0, 0, 0, 0.3);
  --VC-FG-3: rgba(0, 0, 0, 0.1);
  --VC-RED: #fa5151;
  --VC-ORANGE: #fa9d3b;
  --VC-YELLOW: #ffc300;
  --VC-GREEN: #91d300;
  --VC-LIGHTGREEN: #95ec69;
  --VC-BRAND: #07c160;
  --VC-BLUE: #10aeff;
  --VC-INDIGO: #1485ee;
  --VC-PURPLE: #6467f0;
  --VC-LINK: #576b95;
  --VC-TEXTGREEN: #06ae56;
  --VC-FG: black;
  --VC-BG: white;
  --VC-BG-COLOR-ACTIVE: #ececec;
  --VC-WARN-BG: #fff3cc;
  --VC-WARN-BORDER: #ffe799;
  --VC-ERROR-BG: #fedcdc;
  --VC-ERROR-BORDER: #fdb9b9;
  --VC-DOM-TAG-NAME-COLOR: #881280;
  --VC-DOM-ATTRIBUTE-NAME-COLOR: #994500;
  --VC-DOM-ATTRIBUTE-VALUE-COLOR: #1a1aa6;
  --VC-CODE-KEY-FG: #881391;
  --VC-CODE-PRIVATE-KEY-FG: #cfa1d3;
  --VC-CODE-FUNC-FG: #0d22aa;
  --VC-CODE-NUMBER-FG: #1c00cf;
  --VC-CODE-STR-FG: #c41a16;
  --VC-CODE-NULL-FG: #808080;
  color: var(--VC-FG-0);
  font-size: 13px;
  font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
  -webkit-user-select: auto;
  /* global */
  /* compoment */
}
#__vconsole .vc-max-height {
  max-height: 19.23076923em;
}
#__vconsole .vc-max-height-line {
  max-height: 3.38461538em;
}
#__vconsole .vc-min-height {
  min-height: 3.07692308em;
}
#__vconsole dd,
#__vconsole dl,
#__vconsole pre {
  margin: 0;
}
#__vconsole .vc-switch {
  display: block;
  position: fixed;
  right: 0.76923077em;
  bottom: 0.76923077em;
  color: #FFF;
  background-color: var(--VC-BRAND);
  line-height: 1;
  font-size: 1.07692308em;
  padding: 0.61538462em 1.23076923em;
  z-index: 10000;
  border-radius: 0.30769231em;
  box-shadow: 0 0 0.61538462em rgba(0, 0, 0, 0.4);
}
#__vconsole .vc-mask {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 10001;
  -webkit-transition: background 0.3s;
  transition: background 0.3s;
  -webkit-tap-highlight-color: transparent;
  overflow-y: scroll;
}
#__vconsole .vc-panel {
  display: none;
  position: fixed;
  min-height: 85%;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10002;
  background-color: var(--VC-BG-0);
  -webkit-transition: -webkit-transform 0.3s;
  transition: -webkit-transform 0.3s;
  transition: transform 0.3s;
  transition: transform 0.3s, -webkit-transform 0.3s;
  -webkit-transform: translate(0, 100%);
  transform: translate(0, 100%);
}
#__vconsole .vc-tabbar {
  border-bottom: 1px solid var(--VC-FG-3);
  overflow-x: auto;
  height: 3em;
  width: auto;
  white-space: nowrap;
}
#__vconsole .vc-tabbar .vc-tab {
  display: inline-block;
  line-height: 3em;
  padding: 0 1.15384615em;
  border-right: 1px solid var(--VC-FG-3);
  text-decoration: none;
  color: var(--VC-FG-0);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
#__vconsole .vc-tabbar .vc-tab:active {
  background-color: rgba(0, 0, 0, 0.15);
}
#__vconsole .vc-tabbar .vc-tab.vc-actived {
  background-color: var(--VC-BG-1);
}
#__vconsole .vc-content {
  background-color: var(--VC-BG-2);
  overflow-x: hidden;
  overflow-y: auto;
  position: absolute;
  top: 3.07692308em;
  left: 0;
  right: 0;
  bottom: 3.07692308em;
  -webkit-overflow-scrolling: touch;
  margin-bottom: constant(safe-area-inset-bottom);
  margin-bottom: env(safe-area-inset-bottom);
}
#__vconsole .vc-content.vc-has-topbar {
  top: 5.46153846em;
}
#__vconsole .vc-topbar {
  background-color: var(--VC-BG-1);
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-direction: row;
  -moz-box-orient: horizontal;
  -moz-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  width: 100%;
}
#__vconsole .vc-topbar .vc-toptab {
  display: none;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -moz-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  line-height: 2.30769231em;
  padding: 0 1.15384615em;
  border-bottom: 1px solid var(--VC-FG-3);
  text-decoration: none;
  text-align: center;
  color: var(--VC-FG-0);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
#__vconsole .vc-topbar .vc-toptab.vc-toggle {
  display: block;
}
#__vconsole .vc-topbar .vc-toptab:active {
  background-color: rgba(0, 0, 0, 0.15);
}
#__vconsole .vc-topbar .vc-toptab.vc-actived {
  border-bottom: 1px solid var(--VC-INDIGO);
}
#__vconsole .vc-logbox {
  display: none;
  position: relative;
  min-height: 100%;
}
#__vconsole .vc-logbox i {
  font-style: normal;
}
#__vconsole .vc-logbox .vc-log {
  padding-bottom: 6em;
  -webkit-tap-highlight-color: transparent;
}
#__vconsole .vc-logbox .vc-log:empty:before {
  content: "Empty";
  color: var(--VC-FG-1);
  position: absolute;
  top: 45%;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 1.15384615em;
  text-align: center;
}
#__vconsole .vc-logbox .vc-item {
  margin: 0;
  padding: 0.46153846em 0.61538462em;
  overflow: hidden;
  line-height: 1.3;
  border-bottom: 1px solid var(--VC-FG-3);
  word-break: break-word;
}
#__vconsole .vc-logbox .vc-item-info {
  color: var(--VC-PURPLE);
}
#__vconsole .vc-logbox .vc-item-debug {
  color: var(--VC-YELLOW);
}
#__vconsole .vc-logbox .vc-item-warn {
  color: var(--VC-ORANGE);
  border-color: var(--VC-WARN-BORDER);
  background-color: var(--VC-WARN-BG);
}
#__vconsole .vc-logbox .vc-item-error {
  color: var(--VC-RED);
  border-color: var(--VC-ERROR-BORDER);
  background-color: var(--VC-ERROR-BG);
}
#__vconsole .vc-logbox .vc-log.vc-log-partly .vc-item {
  display: none;
}
#__vconsole .vc-logbox .vc-log.vc-log-partly-log .vc-item-log,
#__vconsole .vc-logbox .vc-log.vc-log-partly-info .vc-item-info,
#__vconsole .vc-logbox .vc-log.vc-log-partly-warn .vc-item-warn,
#__vconsole .vc-logbox .vc-log.vc-log-partly-error .vc-item-error {
  display: block;
}
#__vconsole .vc-logbox .vc-item.hide {
  display: none;
}
#__vconsole .vc-logbox .vc-item .vc-item-content {
  margin-right: 4.61538462em;
  display: inline-block;
}
#__vconsole .vc-logbox .vc-item .vc-item-repeat {
  display: inline-block;
  margin-right: 0.30769231em;
  padding: 0 6.5px;
  color: #D7E0EF;
  background-color: #42597F;
  border-radius: 8.66666667px;
}
#__vconsole .vc-logbox .vc-item.vc-item-error .vc-item-repeat {
  color: #901818;
  background-color: var(--VC-RED);
}
#__vconsole .vc-logbox .vc-item.vc-item-warn .vc-item-repeat {
  color: #987D20;
  background-color: #F4BD02;
}
#__vconsole .vc-logbox .vc-item .vc-item-code {
  display: block;
  white-space: pre-wrap;
  overflow: auto;
  position: relative;
}
#__vconsole .vc-logbox .vc-item .vc-item-code.vc-item-code-input,
#__vconsole .vc-logbox .vc-item .vc-item-code.vc-item-code-output {
  padding-left: 0.92307692em;
}
#__vconsole .vc-logbox .vc-item .vc-item-code.vc-item-code-input:before,
#__vconsole .vc-logbox .vc-item .vc-item-code.vc-item-code-output:before {
  content: "›";
  position: absolute;
  top: -0.23076923em;
  left: 0;
  font-size: 1.23076923em;
  color: #6A5ACD;
}
#__vconsole .vc-logbox .vc-item .vc-item-code.vc-item-code-output:before {
  content: "‹";
}
#__vconsole .vc-logbox .vc-item .vc-fold {
  display: block;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-outer {
  display: block;
  font-style: italic;
  padding-left: 0.76923077em;
  position: relative;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-outer:active {
  background-color: var(--VC-BG-COLOR-ACTIVE);
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-outer:before {
  content: "";
  position: absolute;
  top: 0.30769231em;
  left: 0.15384615em;
  width: 0;
  height: 0;
  border: transparent solid 0.30769231em;
  border-left-color: var(--VC-FG-1);
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-outer.vc-toggle:before {
  top: 0.46153846em;
  left: 0;
  border-top-color: var(--VC-FG-1);
  border-left-color: transparent;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-inner {
  display: none;
  margin-left: 0.76923077em;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-inner.vc-toggle {
  display: block;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-inner .vc-code-key {
  margin-left: 0.76923077em;
}
#__vconsole .vc-logbox .vc-item .vc-fold .vc-fold-outer .vc-code-key {
  margin-left: 0;
}
#__vconsole .vc-logbox .vc-code-key {
  color: var(--VC-CODE-KEY-FG);
}
#__vconsole .vc-logbox .vc-code-private-key {
  color: var(--VC-CODE-PRIVATE-KEY-FG);
}
#__vconsole .vc-logbox .vc-code-function {
  color: var(--VC-CODE-FUNC-FG);
  font-style: italic;
}
#__vconsole .vc-logbox .vc-code-number,
#__vconsole .vc-logbox .vc-code-boolean {
  color: var(--VC-CODE-NUMBER-FG);
}
#__vconsole .vc-logbox .vc-code-string {
  color: var(--VC-CODE-STR-FG);
}
#__vconsole .vc-logbox .vc-code-null,
#__vconsole .vc-logbox .vc-code-undefined {
  color: var(--VC-CODE-NULL-FG);
}
#__vconsole .vc-logbox .vc-cmd {
  position: absolute;
  height: 3.07692308em;
  left: 0;
  right: 0;
  bottom: 41px;
  border-top: 1px solid var(--VC-FG-3);
  display: block!important;
}
#__vconsole .vc-logbox .vc-cmd.vc-filter {
  bottom: 0;
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-input-wrap {
  display: block;
  height: 2.15384615em;
  margin-right: 3.07692308em;
  padding: 0.46153846em 0.61538462em;
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-input {
  width: 100%;
  border: none;
  resize: none;
  outline: none;
  padding: 0;
  font-size: 0.92307692em;
  background-color: transparent;
  color: var(--VC-FG-0);
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-input::-webkit-input-placeholder {
  line-height: 2.15384615em;
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-btn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3.07692308em;
  border: none;
  background-color: var(--VC-BG-0);
  color: var(--VC-FG-0);
  outline: none;
  -webkit-touch-callout: none;
  font-size: 1em;
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-btn:active {
  background-color: rgba(0, 0, 0, 0.15);
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-prompted {
  position: fixed;
  width: 100%;
  background-color: var(--VC-BG-3);
  border: 1px solid var(--VC-FG-3);
  overflow-x: scroll;
  display: none;
}
#__vconsole .vc-logbox .vc-cmd .vc-cmd-prompted li {
  list-style: none;
  line-height: 30px;
  padding: 0 0.46153846em;
  border-bottom: 1px solid var(--VC-FG-3);
}
#__vconsole .vc-logbox .vc-group .vc-group-preview {
  -webkit-touch-callout: none;
}
#__vconsole .vc-logbox .vc-group .vc-group-preview:active {
  background-color: var(--VC-BG-COLOR-ACTIVE);
}
#__vconsole .vc-logbox .vc-group .vc-group-detail {
  display: none;
  padding: 0 0 0.76923077em 1.53846154em;
  border-bottom: 1px solid var(--VC-FG-3);
}
#__vconsole .vc-logbox .vc-group.vc-actived .vc-group-detail {
  display: block;
  background-color: var(--VC-BG-1);
}
#__vconsole .vc-logbox .vc-group.vc-actived .vc-table-row {
  background-color: var(--VC-BG-2);
}
#__vconsole .vc-logbox .vc-group.vc-actived .vc-group-preview {
  background-color: var(--VC-BG-1);
}
#__vconsole .vc-logbox .vc-table .vc-table-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-direction: row;
  -moz-box-orient: horizontal;
  -moz-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: wrap;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  overflow: hidden;
  border-bottom: 1px solid var(--VC-FG-3);
}
#__vconsole .vc-logbox .vc-table .vc-table-row.vc-left-border {
  border-left: 1px solid var(--VC-FG-3);
}
#__vconsole .vc-logbox .vc-table .vc-table-col {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -moz-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  padding: 0.23076923em 0.30769231em;
  border-left: 1px solid var(--VC-FG-3);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  /*white-space: nowrap;
        text-overflow: ellipsis;*/
  -webkit-overflow-scrolling: touch;
}
#__vconsole .vc-logbox .vc-table .vc-table-col:first-child {
  border: none;
}
#__vconsole .vc-logbox .vc-table .vc-small .vc-table-col {
  padding: 0 0.30769231em;
  font-size: 0.92307692em;
}
#__vconsole .vc-logbox .vc-table .vc-table-col-2 {
  -webkit-box-flex: 2;
  -webkit-flex: 2;
  -moz-box-flex: 2;
  -ms-flex: 2;
  flex: 2;
}
#__vconsole .vc-logbox .vc-table .vc-table-col-3 {
  -webkit-box-flex: 3;
  -webkit-flex: 3;
  -moz-box-flex: 3;
  -ms-flex: 3;
  flex: 3;
}
#__vconsole .vc-logbox .vc-table .vc-table-col-4 {
  -webkit-box-flex: 4;
  -webkit-flex: 4;
  -moz-box-flex: 4;
  -ms-flex: 4;
  flex: 4;
}
#__vconsole .vc-logbox .vc-table .vc-table-col-5 {
  -webkit-box-flex: 5;
  -webkit-flex: 5;
  -moz-box-flex: 5;
  -ms-flex: 5;
  flex: 5;
}
#__vconsole .vc-logbox .vc-table .vc-table-col-6 {
  -webkit-box-flex: 6;
  -webkit-flex: 6;
  -moz-box-flex: 6;
  -ms-flex: 6;
  flex: 6;
}
#__vconsole .vc-logbox .vc-table .vc-table-row-error {
  border-color: var(--VC-ERROR-BORDER);
  background-color: var(--VC-ERROR-BG);
}
#__vconsole .vc-logbox .vc-table .vc-table-row-error .vc-table-col {
  color: var(--VC-RED);
  border-color: var(--VC-ERROR-BORDER);
}
#__vconsole .vc-logbox .vc-table .vc-table-col-title {
  font-weight: bold;
}
#__vconsole .vc-logbox.vc-actived {
  display: block;
}
#__vconsole .vc-toolbar {
  border-top: 1px solid var(--VC-FG-3);
  line-height: 3em;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -webkit-flex-direction: row;
  -moz-box-orient: horizontal;
  -moz-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
}
#__vconsole .vc-toolbar .vc-tool {
  display: none;
  text-decoration: none;
  color: var(--VC-FG-0);
  width: 50%;
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  -moz-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  text-align: center;
  position: relative;
  -webkit-touch-callout: none;
}
#__vconsole .vc-toolbar .vc-tool.vc-toggle,
#__vconsole .vc-toolbar .vc-tool.vc-global-tool {
  display: block;
}
#__vconsole .vc-toolbar .vc-tool:active {
  background-color: rgba(0, 0, 0, 0.15);
}
#__vconsole .vc-toolbar .vc-tool:after {
  content: " ";
  position: absolute;
  top: 0.53846154em;
  bottom: 0.53846154em;
  right: 0;
  border-left: 1px solid var(--VC-FG-3);
}
#__vconsole .vc-toolbar .vc-tool-last:after {
  border: none;
}
@supports (bottom: constant(safe-area-inset-bottom)) or (bottom: env(safe-area-inset-bottom)) {
  #__vconsole .vc-toolbar,
  #__vconsole .vc-switch {
    bottom: constant(safe-area-inset-bottom);
    bottom: env(safe-area-inset-bottom);
  }
}
#__vconsole.vc-toggle .vc-switch {
  display: none;
}
#__vconsole.vc-toggle .vc-mask {
  background: rgba(0, 0, 0, 0.6);
  display: block;
}
#__vconsole.vc-toggle .vc-panel {
  -webkit-transform: translate(0, 0);
  transform: translate(0, 0);
}
@media (prefers-color-scheme: dark) {
  #__vconsole:not([data-theme="light"]) {
    --VC-BG-0: #191919;
    --VC-BG-1: #1f1f1f;
    --VC-BG-2: #232323;
    --VC-BG-3: #2f2f2f;
    --VC-BG-4: #606060;
    --VC-BG-5: #2c2c2c;
    --VC-FG-0: rgba(255, 255, 255, 0.8);
    --VC-FG-HALF: rgba(255, 255, 255, 0.6);
    --VC-FG-1: rgba(255, 255, 255, 0.5);
    --VC-FG-2: rgba(255, 255, 255, 0.3);
    --VC-FG-3: rgba(255, 255, 255, 0.05);
    --VC-RED: #fa5151;
    --VC-ORANGE: #c87d2f;
    --VC-YELLOW: #cc9c00;
    --VC-GREEN: #74a800;
    --VC-LIGHTGREEN: #28b561;
    --VC-BRAND: #07c160;
    --VC-BLUE: #10aeff;
    --VC-INDIGO: #1196ff;
    --VC-PURPLE: #8183ff;
    --VC-LINK: #7d90a9;
    --VC-TEXTGREEN: #259c5c;
    --VC-FG: white;
    --VC-BG: black;
    --VC-BG-COLOR-ACTIVE: #282828;
    --VC-WARN-BG: #332700;
    --VC-WARN-BORDER: #664e00;
    --VC-ERROR-BG: #321010;
    --VC-ERROR-BORDER: #642020;
    --VC-DOM-TAG-NAME-COLOR: #5DB0D7;
    --VC-DOM-ATTRIBUTE-NAME-COLOR: #9BBBDC;
    --VC-DOM-ATTRIBUTE-VALUE-COLOR: #f29766;
    --VC-CODE-KEY-FG: #e36eec;
    --VC-CODE-PRIVATE-KEY-FG: #f4c5f7;
    --VC-CODE-FUNC-FG: #556af2;
    --VC-CODE-NUMBER-FG: #9980ff;
    --VC-CODE-STR-FG: #e93f3b;
    --VC-CODE-NULL-FG: #808080;
  }
}
#__vconsole[data-theme="dark"] {
  --VC-BG-0: #191919;
  --VC-BG-1: #1f1f1f;
  --VC-BG-2: #232323;
  --VC-BG-3: #2f2f2f;
  --VC-BG-4: #606060;
  --VC-BG-5: #2c2c2c;
  --VC-FG-0: rgba(255, 255, 255, 0.8);
  --VC-FG-HALF: rgba(255, 255, 255, 0.6);
  --VC-FG-1: rgba(255, 255, 255, 0.5);
  --VC-FG-2: rgba(255, 255, 255, 0.3);
  --VC-FG-3: rgba(255, 255, 255, 0.05);
  --VC-RED: #fa5151;
  --VC-ORANGE: #c87d2f;
  --VC-YELLOW: #cc9c00;
  --VC-GREEN: #74a800;
  --VC-LIGHTGREEN: #28b561;
  --VC-BRAND: #07c160;
  --VC-BLUE: #10aeff;
  --VC-INDIGO: #1196ff;
  --VC-PURPLE: #8183ff;
  --VC-LINK: #7d90a9;
  --VC-TEXTGREEN: #259c5c;
  --VC-FG: white;
  --VC-BG: black;
  --VC-BG-COLOR-ACTIVE: #282828;
  --VC-WARN-BG: #332700;
  --VC-WARN-BORDER: #664e00;
  --VC-ERROR-BG: #321010;
  --VC-ERROR-BORDER: #642020;
  --VC-DOM-TAG-NAME-COLOR: #5DB0D7;
  --VC-DOM-ATTRIBUTE-NAME-COLOR: #9BBBDC;
  --VC-DOM-ATTRIBUTE-VALUE-COLOR: #f29766;
  --VC-CODE-KEY-FG: #e36eec;
  --VC-CODE-PRIVATE-KEY-FG: #f4c5f7;
  --VC-CODE-FUNC-FG: #556af2;
  --VC-CODE-NUMBER-FG: #9980ff;
  --VC-CODE-STR-FG: #e93f3b;
  --VC-CODE-NULL-FG: #808080;
}
</style><style>/* color */
.vcelm-node {
  color: var(--VC-DOM-TAG-NAME-COLOR);
}
.vcelm-k {
  color: var(--VC-DOM-ATTRIBUTE-NAME-COLOR);
}
.vcelm-v {
  color: var(--VC-DOM-ATTRIBUTE-VALUE-COLOR);
}
/* layout */
.vcelm-l {
  padding-left: 8px;
  position: relative;
  word-wrap: break-word;
  line-height: 1;
}
/*.vcelm-l.vcelm-noc {
  padding-left: 0;
}*/
.vcelm-l.vc-toggle > .vcelm-node {
  display: block;
}
.vcelm-l .vcelm-node:active {
  background-color: var(--VC-BG-COLOR-ACTIVE);
}
.vcelm-l.vcelm-noc .vcelm-node:active {
  background-color: transparent;
}
.vcelm-t {
  white-space: pre-wrap;
  word-wrap: break-word;
}
/* level */
.vcelm-l .vcelm-l {
  display: none;
}
.vcelm-l.vc-toggle > .vcelm-l {
  margin-left: 4px;
  display: block;
}
/* arrow */
.vcelm-l:before {
  content: "";
  display: block;
  position: absolute;
  top: 6px;
  left: 3px;
  width: 0;
  height: 0;
  border: transparent solid 3px;
  border-left-color: var(--VC-FG-1);
}
.vcelm-l.vc-toggle:before {
  display: block;
  top: 6px;
  left: 0;
  border-top-color: var(--VC-FG-1);
  border-left-color: transparent;
}
.vcelm-l.vcelm-noc:before {
  display: none;
}
</style><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/vendors_layouts__index_p__Area__GDS-2020_p__Area__HarmonyOSForerunner_p__ArticleDetail_p__Home_p__Li_a66cec21.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/vendors_layouts__index_p__ArticleDetail_p__Home_p__Live_p__Live__Add_p__QuestionDetail_p__Questions__c0b66e4e.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/vendors_layouts__index.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/layouts__index_p__Live__Add_p__Video__Add_p__Write.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/layouts__index.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/3.js.下载"></script><link rel="stylesheet" type="text/css" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/vendors_p__ArticleDetail_p__Live_p__QuestionDetail_p__Video.chunk.css"><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/vendors_p__ArticleDetail_p__Live_p__QuestionDetail_p__Video.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/p__ArticleDetail.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/57.js.下载"></script><link rel="stylesheet" type="text/css" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/2.chunk.css"><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/2.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/7.js.下载"></script><script charset="utf-8" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/9.js.下载"></script><script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/katexCssLoader.js.下载"></script><meta name="event-object" value="{&quot;current&quot;: [&quot;article&quot;, [&quot;1190000039073805&quot;]], &quot;root&quot;: [&quot;article&quot;, &quot;1190000039073805&quot;]}" id="SFEventObject" data-react-helmet="true"><script async="true" defer="true" data-domain="segmentfault.com" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/plausible.js.下载" data-react-helmet="true"></script><script type="application/ld+json" data-react-helmet="true">{
            "@context": "https://schema.org",
            "@type": "Article",
            "mainEntityOfPage": {
              "@type": "WebPage",
              "@id": "https://google.com/article"
            },
            "name": "Springboot整合quartz实现定时任务的动态加载",
            "headline": "Springboot整合quartz实现定时任务的动态加载",
            "image": "https://cdn.segmentfault.com/r-8b3ead20/touch-icon.png",
            "datePublished": "2021-01-24T05:33:24.000Z",
            "dateModified": "2021-01-24T06:13:44.000Z",
            "url": "https://segmentfault.com/a/1190000039073805",
            "author": {
              "@type": "Person",
              "name": "超级大咸鱼"
            },
            "publisher": {
              "@type": "Organization",
              "name": "SegmentFault",
              "logo": {
                "@type": "ImageObject",
                "url":
                  "https://assets.segmentfault.com/v-5fc4b0b2/global/img/static/touch-icon.png"
              }
            }
          }</script><style type="text/css">
/* stylelint-disable font-family-no-missing-generic-family-keyword */
@font-face {
  font-family: 'KaTeX_AMS';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_AMS-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_AMS-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_AMS-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Caligraphic';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Bold.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Bold.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Bold.ttf) format('truetype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Caligraphic';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Caligraphic-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Fraktur';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Bold.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Bold.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Bold.ttf) format('truetype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Fraktur';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Fraktur-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Main';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Bold.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Bold.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Bold.ttf) format('truetype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Main';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-BoldItalic.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-BoldItalic.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-BoldItalic.ttf) format('truetype');
  font-weight: bold;
  font-style: italic;
}
@font-face {
  font-family: 'KaTeX_Main';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Italic.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Italic.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Italic.ttf) format('truetype');
  font-weight: normal;
  font-style: italic;
}
@font-face {
  font-family: 'KaTeX_Main';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Main-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Math';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-BoldItalic.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-BoldItalic.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-BoldItalic.ttf) format('truetype');
  font-weight: bold;
  font-style: italic;
}
@font-face {
  font-family: 'KaTeX_Math';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-Italic.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-Italic.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Math-Italic.ttf) format('truetype');
  font-weight: normal;
  font-style: italic;
}
@font-face {
  font-family: 'KaTeX_SansSerif';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Bold.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Bold.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Bold.ttf) format('truetype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_SansSerif';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Italic.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Italic.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Italic.ttf) format('truetype');
  font-weight: normal;
  font-style: italic;
}
@font-face {
  font-family: 'KaTeX_SansSerif';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_SansSerif-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Script';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Script-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Script-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Script-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Size1';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size1-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size1-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size1-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Size2';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size2-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size2-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size2-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Size3';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size3-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size3-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size3-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Size4';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size4-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size4-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Size4-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'KaTeX_Typewriter';
  src: url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Typewriter-Regular.woff2) format('woff2'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Typewriter-Regular.woff) format('woff'), url(https://cdn.segmentfault.com/r-8b3ead20/fonts/katex/KaTeX_Typewriter-Regular.ttf) format('truetype');
  font-weight: normal;
  font-style: normal;
}
.katex {
  font: normal 1.21em KaTeX_Main, Times New Roman, serif;
  line-height: 1.2;
  text-indent: 0;
  text-rendering: auto;
  border-color: currentColor;
}
.katex * {
  -ms-high-contrast-adjust: none !important;
}
.katex .katex-version::after {
  content: "0.12.0";
}
.katex .katex-mathml {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}
.katex .katex-html {
  /* 
ewline is an empty block at top level, between .base elements */
}
.katex .katex-html > .newline {
  display: block;
}
.katex .base {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  width: min-content;
}
.katex .strut {
  display: inline-block;
}
.katex .textbf {
  font-weight: bold;
}
.katex .textit {
  font-style: italic;
}
.katex .textrm {
  font-family: KaTeX_Main;
}
.katex .textsf {
  font-family: KaTeX_SansSerif;
}
.katex .texttt {
  font-family: KaTeX_Typewriter;
}
.katex .mathnormal {
  font-family: KaTeX_Math;
  font-style: italic;
}
.katex .mathit {
  font-family: KaTeX_Main;
  font-style: italic;
}
.katex .mathrm {
  font-style: normal;
}
.katex .mathbf {
  font-family: KaTeX_Main;
  font-weight: bold;
}
.katex .boldsymbol {
  font-family: KaTeX_Math;
  font-weight: bold;
  font-style: italic;
}
.katex .amsrm {
  font-family: KaTeX_AMS;
}
.katex .mathbb,
.katex .textbb {
  font-family: KaTeX_AMS;
}
.katex .mathcal {
  font-family: KaTeX_Caligraphic;
}
.katex .mathfrak,
.katex .textfrak {
  font-family: KaTeX_Fraktur;
}
.katex .mathtt {
  font-family: KaTeX_Typewriter;
}
.katex .mathscr,
.katex .textscr {
  font-family: KaTeX_Script;
}
.katex .mathsf,
.katex .textsf {
  font-family: KaTeX_SansSerif;
}
.katex .mathboldsf,
.katex .textboldsf {
  font-family: KaTeX_SansSerif;
  font-weight: bold;
}
.katex .mathitsf,
.katex .textitsf {
  font-family: KaTeX_SansSerif;
  font-style: italic;
}
.katex .mainrm {
  font-family: KaTeX_Main;
  font-style: normal;
}
.katex .vlist-t {
  display: inline-table;
  table-layout: fixed;
  border-collapse: collapse;
}
.katex .vlist-r {
  display: table-row;
}
.katex .vlist {
  display: table-cell;
  vertical-align: bottom;
  position: relative;
}
.katex .vlist > span {
  display: block;
  height: 0;
  position: relative;
}
.katex .vlist > span > span {
  display: inline-block;
}
.katex .vlist > span > .pstrut {
  overflow: hidden;
  width: 0;
}
.katex .vlist-t2 {
  margin-right: -2px;
}
.katex .vlist-s {
  display: table-cell;
  vertical-align: bottom;
  font-size: 1px;
  width: 2px;
  min-width: 2px;
}
.katex .vbox {
  display: -ms-inline-flexbox;
  display: inline-flex;
  -ms-flex-direction: column;
  flex-direction: column;
  align-items: baseline;
}
.katex .hbox {
  display: -ms-inline-flexbox;
  display: inline-flex;
  -ms-flex-direction: row;
  flex-direction: row;
  width: 100%;
}
.katex .thinbox {
  display: inline-flex;
  flex-direction: row;
  width: 0;
  max-width: 0;
}
.katex .msupsub {
  text-align: left;
}
.katex .mfrac > span > span {
  text-align: center;
}
.katex .mfrac .frac-line {
  display: inline-block;
  width: 100%;
  border-bottom-style: solid;
}
.katex .mfrac .frac-line,
.katex .overline .overline-line,
.katex .underline .underline-line,
.katex .hline,
.katex .hdashline,
.katex .rule {
  min-height: 1px;
}
.katex .mspace {
  display: inline-block;
}
.katex .llap,
.katex .rlap,
.katex .clap {
  width: 0;
  position: relative;
}
.katex .llap > .inner,
.katex .rlap > .inner,
.katex .clap > .inner {
  position: absolute;
}
.katex .llap > .fix,
.katex .rlap > .fix,
.katex .clap > .fix {
  display: inline-block;
}
.katex .llap > .inner {
  right: 0;
}
.katex .rlap > .inner,
.katex .clap > .inner {
  left: 0;
}
.katex .clap > .inner > span {
  margin-left: -50%;
  margin-right: 50%;
}
.katex .rule {
  display: inline-block;
  border: solid 0;
  position: relative;
}
.katex .overline .overline-line,
.katex .underline .underline-line,
.katex .hline {
  display: inline-block;
  width: 100%;
  border-bottom-style: solid;
}
.katex .hdashline {
  display: inline-block;
  width: 100%;
  border-bottom-style: dashed;
}
.katex .sqrt > .root {
  margin-left: 0.27777778em;
  margin-right: -0.55555556em;
}
.katex .sizing.reset-size1.size1,
.katex .fontsize-ensurer.reset-size1.size1 {
  font-size: 1em;
}
.katex .sizing.reset-size1.size2,
.katex .fontsize-ensurer.reset-size1.size2 {
  font-size: 1.2em;
}
.katex .sizing.reset-size1.size3,
.katex .fontsize-ensurer.reset-size1.size3 {
  font-size: 1.4em;
}
.katex .sizing.reset-size1.size4,
.katex .fontsize-ensurer.reset-size1.size4 {
  font-size: 1.6em;
}
.katex .sizing.reset-size1.size5,
.katex .fontsize-ensurer.reset-size1.size5 {
  font-size: 1.8em;
}
.katex .sizing.reset-size1.size6,
.katex .fontsize-ensurer.reset-size1.size6 {
  font-size: 2em;
}
.katex .sizing.reset-size1.size7,
.katex .fontsize-ensurer.reset-size1.size7 {
  font-size: 2.4em;
}
.katex .sizing.reset-size1.size8,
.katex .fontsize-ensurer.reset-size1.size8 {
  font-size: 2.88em;
}
.katex .sizing.reset-size1.size9,
.katex .fontsize-ensurer.reset-size1.size9 {
  font-size: 3.456em;
}
.katex .sizing.reset-size1.size10,
.katex .fontsize-ensurer.reset-size1.size10 {
  font-size: 4.148em;
}
.katex .sizing.reset-size1.size11,
.katex .fontsize-ensurer.reset-size1.size11 {
  font-size: 4.976em;
}
.katex .sizing.reset-size2.size1,
.katex .fontsize-ensurer.reset-size2.size1 {
  font-size: 0.83333333em;
}
.katex .sizing.reset-size2.size2,
.katex .fontsize-ensurer.reset-size2.size2 {
  font-size: 1em;
}
.katex .sizing.reset-size2.size3,
.katex .fontsize-ensurer.reset-size2.size3 {
  font-size: 1.16666667em;
}
.katex .sizing.reset-size2.size4,
.katex .fontsize-ensurer.reset-size2.size4 {
  font-size: 1.33333333em;
}
.katex .sizing.reset-size2.size5,
.katex .fontsize-ensurer.reset-size2.size5 {
  font-size: 1.5em;
}
.katex .sizing.reset-size2.size6,
.katex .fontsize-ensurer.reset-size2.size6 {
  font-size: 1.66666667em;
}
.katex .sizing.reset-size2.size7,
.katex .fontsize-ensurer.reset-size2.size7 {
  font-size: 2em;
}
.katex .sizing.reset-size2.size8,
.katex .fontsize-ensurer.reset-size2.size8 {
  font-size: 2.4em;
}
.katex .sizing.reset-size2.size9,
.katex .fontsize-ensurer.reset-size2.size9 {
  font-size: 2.88em;
}
.katex .sizing.reset-size2.size10,
.katex .fontsize-ensurer.reset-size2.size10 {
  font-size: 3.45666667em;
}
.katex .sizing.reset-size2.size11,
.katex .fontsize-ensurer.reset-size2.size11 {
  font-size: 4.14666667em;
}
.katex .sizing.reset-size3.size1,
.katex .fontsize-ensurer.reset-size3.size1 {
  font-size: 0.71428571em;
}
.katex .sizing.reset-size3.size2,
.katex .fontsize-ensurer.reset-size3.size2 {
  font-size: 0.85714286em;
}
.katex .sizing.reset-size3.size3,
.katex .fontsize-ensurer.reset-size3.size3 {
  font-size: 1em;
}
.katex .sizing.reset-size3.size4,
.katex .fontsize-ensurer.reset-size3.size4 {
  font-size: 1.14285714em;
}
.katex .sizing.reset-size3.size5,
.katex .fontsize-ensurer.reset-size3.size5 {
  font-size: 1.28571429em;
}
.katex .sizing.reset-size3.size6,
.katex .fontsize-ensurer.reset-size3.size6 {
  font-size: 1.42857143em;
}
.katex .sizing.reset-size3.size7,
.katex .fontsize-ensurer.reset-size3.size7 {
  font-size: 1.71428571em;
}
.katex .sizing.reset-size3.size8,
.katex .fontsize-ensurer.reset-size3.size8 {
  font-size: 2.05714286em;
}
.katex .sizing.reset-size3.size9,
.katex .fontsize-ensurer.reset-size3.size9 {
  font-size: 2.46857143em;
}
.katex .sizing.reset-size3.size10,
.katex .fontsize-ensurer.reset-size3.size10 {
  font-size: 2.96285714em;
}
.katex .sizing.reset-size3.size11,
.katex .fontsize-ensurer.reset-size3.size11 {
  font-size: 3.55428571em;
}
.katex .sizing.reset-size4.size1,
.katex .fontsize-ensurer.reset-size4.size1 {
  font-size: 0.625em;
}
.katex .sizing.reset-size4.size2,
.katex .fontsize-ensurer.reset-size4.size2 {
  font-size: 0.75em;
}
.katex .sizing.reset-size4.size3,
.katex .fontsize-ensurer.reset-size4.size3 {
  font-size: 0.875em;
}
.katex .sizing.reset-size4.size4,
.katex .fontsize-ensurer.reset-size4.size4 {
  font-size: 1em;
}
.katex .sizing.reset-size4.size5,
.katex .fontsize-ensurer.reset-size4.size5 {
  font-size: 1.125em;
}
.katex .sizing.reset-size4.size6,
.katex .fontsize-ensurer.reset-size4.size6 {
  font-size: 1.25em;
}
.katex .sizing.reset-size4.size7,
.katex .fontsize-ensurer.reset-size4.size7 {
  font-size: 1.5em;
}
.katex .sizing.reset-size4.size8,
.katex .fontsize-ensurer.reset-size4.size8 {
  font-size: 1.8em;
}
.katex .sizing.reset-size4.size9,
.katex .fontsize-ensurer.reset-size4.size9 {
  font-size: 2.16em;
}
.katex .sizing.reset-size4.size10,
.katex .fontsize-ensurer.reset-size4.size10 {
  font-size: 2.5925em;
}
.katex .sizing.reset-size4.size11,
.katex .fontsize-ensurer.reset-size4.size11 {
  font-size: 3.11em;
}
.katex .sizing.reset-size5.size1,
.katex .fontsize-ensurer.reset-size5.size1 {
  font-size: 0.55555556em;
}
.katex .sizing.reset-size5.size2,
.katex .fontsize-ensurer.reset-size5.size2 {
  font-size: 0.66666667em;
}
.katex .sizing.reset-size5.size3,
.katex .fontsize-ensurer.reset-size5.size3 {
  font-size: 0.77777778em;
}
.katex .sizing.reset-size5.size4,
.katex .fontsize-ensurer.reset-size5.size4 {
  font-size: 0.88888889em;
}
.katex .sizing.reset-size5.size5,
.katex .fontsize-ensurer.reset-size5.size5 {
  font-size: 1em;
}
.katex .sizing.reset-size5.size6,
.katex .fontsize-ensurer.reset-size5.size6 {
  font-size: 1.11111111em;
}
.katex .sizing.reset-size5.size7,
.katex .fontsize-ensurer.reset-size5.size7 {
  font-size: 1.33333333em;
}
.katex .sizing.reset-size5.size8,
.katex .fontsize-ensurer.reset-size5.size8 {
  font-size: 1.6em;
}
.katex .sizing.reset-size5.size9,
.katex .fontsize-ensurer.reset-size5.size9 {
  font-size: 1.92em;
}
.katex .sizing.reset-size5.size10,
.katex .fontsize-ensurer.reset-size5.size10 {
  font-size: 2.30444444em;
}
.katex .sizing.reset-size5.size11,
.katex .fontsize-ensurer.reset-size5.size11 {
  font-size: 2.76444444em;
}
.katex .sizing.reset-size6.size1,
.katex .fontsize-ensurer.reset-size6.size1 {
  font-size: 0.5em;
}
.katex .sizing.reset-size6.size2,
.katex .fontsize-ensurer.reset-size6.size2 {
  font-size: 0.6em;
}
.katex .sizing.reset-size6.size3,
.katex .fontsize-ensurer.reset-size6.size3 {
  font-size: 0.7em;
}
.katex .sizing.reset-size6.size4,
.katex .fontsize-ensurer.reset-size6.size4 {
  font-size: 0.8em;
}
.katex .sizing.reset-size6.size5,
.katex .fontsize-ensurer.reset-size6.size5 {
  font-size: 0.9em;
}
.katex .sizing.reset-size6.size6,
.katex .fontsize-ensurer.reset-size6.size6 {
  font-size: 1em;
}
.katex .sizing.reset-size6.size7,
.katex .fontsize-ensurer.reset-size6.size7 {
  font-size: 1.2em;
}
.katex .sizing.reset-size6.size8,
.katex .fontsize-ensurer.reset-size6.size8 {
  font-size: 1.44em;
}
.katex .sizing.reset-size6.size9,
.katex .fontsize-ensurer.reset-size6.size9 {
  font-size: 1.728em;
}
.katex .sizing.reset-size6.size10,
.katex .fontsize-ensurer.reset-size6.size10 {
  font-size: 2.074em;
}
.katex .sizing.reset-size6.size11,
.katex .fontsize-ensurer.reset-size6.size11 {
  font-size: 2.488em;
}
.katex .sizing.reset-size7.size1,
.katex .fontsize-ensurer.reset-size7.size1 {
  font-size: 0.41666667em;
}
.katex .sizing.reset-size7.size2,
.katex .fontsize-ensurer.reset-size7.size2 {
  font-size: 0.5em;
}
.katex .sizing.reset-size7.size3,
.katex .fontsize-ensurer.reset-size7.size3 {
  font-size: 0.58333333em;
}
.katex .sizing.reset-size7.size4,
.katex .fontsize-ensurer.reset-size7.size4 {
  font-size: 0.66666667em;
}
.katex .sizing.reset-size7.size5,
.katex .fontsize-ensurer.reset-size7.size5 {
  font-size: 0.75em;
}
.katex .sizing.reset-size7.size6,
.katex .fontsize-ensurer.reset-size7.size6 {
  font-size: 0.83333333em;
}
.katex .sizing.reset-size7.size7,
.katex .fontsize-ensurer.reset-size7.size7 {
  font-size: 1em;
}
.katex .sizing.reset-size7.size8,
.katex .fontsize-ensurer.reset-size7.size8 {
  font-size: 1.2em;
}
.katex .sizing.reset-size7.size9,
.katex .fontsize-ensurer.reset-size7.size9 {
  font-size: 1.44em;
}
.katex .sizing.reset-size7.size10,
.katex .fontsize-ensurer.reset-size7.size10 {
  font-size: 1.72833333em;
}
.katex .sizing.reset-size7.size11,
.katex .fontsize-ensurer.reset-size7.size11 {
  font-size: 2.07333333em;
}
.katex .sizing.reset-size8.size1,
.katex .fontsize-ensurer.reset-size8.size1 {
  font-size: 0.34722222em;
}
.katex .sizing.reset-size8.size2,
.katex .fontsize-ensurer.reset-size8.size2 {
  font-size: 0.41666667em;
}
.katex .sizing.reset-size8.size3,
.katex .fontsize-ensurer.reset-size8.size3 {
  font-size: 0.48611111em;
}
.katex .sizing.reset-size8.size4,
.katex .fontsize-ensurer.reset-size8.size4 {
  font-size: 0.55555556em;
}
.katex .sizing.reset-size8.size5,
.katex .fontsize-ensurer.reset-size8.size5 {
  font-size: 0.625em;
}
.katex .sizing.reset-size8.size6,
.katex .fontsize-ensurer.reset-size8.size6 {
  font-size: 0.69444444em;
}
.katex .sizing.reset-size8.size7,
.katex .fontsize-ensurer.reset-size8.size7 {
  font-size: 0.83333333em;
}
.katex .sizing.reset-size8.size8,
.katex .fontsize-ensurer.reset-size8.size8 {
  font-size: 1em;
}
.katex .sizing.reset-size8.size9,
.katex .fontsize-ensurer.reset-size8.size9 {
  font-size: 1.2em;
}
.katex .sizing.reset-size8.size10,
.katex .fontsize-ensurer.reset-size8.size10 {
  font-size: 1.44027778em;
}
.katex .sizing.reset-size8.size11,
.katex .fontsize-ensurer.reset-size8.size11 {
  font-size: 1.72777778em;
}
.katex .sizing.reset-size9.size1,
.katex .fontsize-ensurer.reset-size9.size1 {
  font-size: 0.28935185em;
}
.katex .sizing.reset-size9.size2,
.katex .fontsize-ensurer.reset-size9.size2 {
  font-size: 0.34722222em;
}
.katex .sizing.reset-size9.size3,
.katex .fontsize-ensurer.reset-size9.size3 {
  font-size: 0.40509259em;
}
.katex .sizing.reset-size9.size4,
.katex .fontsize-ensurer.reset-size9.size4 {
  font-size: 0.46296296em;
}
.katex .sizing.reset-size9.size5,
.katex .fontsize-ensurer.reset-size9.size5 {
  font-size: 0.52083333em;
}
.katex .sizing.reset-size9.size6,
.katex .fontsize-ensurer.reset-size9.size6 {
  font-size: 0.5787037em;
}
.katex .sizing.reset-size9.size7,
.katex .fontsize-ensurer.reset-size9.size7 {
  font-size: 0.69444444em;
}
.katex .sizing.reset-size9.size8,
.katex .fontsize-ensurer.reset-size9.size8 {
  font-size: 0.83333333em;
}
.katex .sizing.reset-size9.size9,
.katex .fontsize-ensurer.reset-size9.size9 {
  font-size: 1em;
}
.katex .sizing.reset-size9.size10,
.katex .fontsize-ensurer.reset-size9.size10 {
  font-size: 1.20023148em;
}
.katex .sizing.reset-size9.size11,
.katex .fontsize-ensurer.reset-size9.size11 {
  font-size: 1.43981481em;
}
.katex .sizing.reset-size10.size1,
.katex .fontsize-ensurer.reset-size10.size1 {
  font-size: 0.24108004em;
}
.katex .sizing.reset-size10.size2,
.katex .fontsize-ensurer.reset-size10.size2 {
  font-size: 0.28929605em;
}
.katex .sizing.reset-size10.size3,
.katex .fontsize-ensurer.reset-size10.size3 {
  font-size: 0.33751205em;
}
.katex .sizing.reset-size10.size4,
.katex .fontsize-ensurer.reset-size10.size4 {
  font-size: 0.38572806em;
}
.katex .sizing.reset-size10.size5,
.katex .fontsize-ensurer.reset-size10.size5 {
  font-size: 0.43394407em;
}
.katex .sizing.reset-size10.size6,
.katex .fontsize-ensurer.reset-size10.size6 {
  font-size: 0.48216008em;
}
.katex .sizing.reset-size10.size7,
.katex .fontsize-ensurer.reset-size10.size7 {
  font-size: 0.57859209em;
}
.katex .sizing.reset-size10.size8,
.katex .fontsize-ensurer.reset-size10.size8 {
  font-size: 0.69431051em;
}
.katex .sizing.reset-size10.size9,
.katex .fontsize-ensurer.reset-size10.size9 {
  font-size: 0.83317261em;
}
.katex .sizing.reset-size10.size10,
.katex .fontsize-ensurer.reset-size10.size10 {
  font-size: 1em;
}
.katex .sizing.reset-size10.size11,
.katex .fontsize-ensurer.reset-size10.size11 {
  font-size: 1.19961427em;
}
.katex .sizing.reset-size11.size1,
.katex .fontsize-ensurer.reset-size11.size1 {
  font-size: 0.20096463em;
}
.katex .sizing.reset-size11.size2,
.katex .fontsize-ensurer.reset-size11.size2 {
  font-size: 0.24115756em;
}
.katex .sizing.reset-size11.size3,
.katex .fontsize-ensurer.reset-size11.size3 {
  font-size: 0.28135048em;
}
.katex .sizing.reset-size11.size4,
.katex .fontsize-ensurer.reset-size11.size4 {
  font-size: 0.32154341em;
}
.katex .sizing.reset-size11.size5,
.katex .fontsize-ensurer.reset-size11.size5 {
  font-size: 0.36173633em;
}
.katex .sizing.reset-size11.size6,
.katex .fontsize-ensurer.reset-size11.size6 {
  font-size: 0.40192926em;
}
.katex .sizing.reset-size11.size7,
.katex .fontsize-ensurer.reset-size11.size7 {
  font-size: 0.48231511em;
}
.katex .sizing.reset-size11.size8,
.katex .fontsize-ensurer.reset-size11.size8 {
  font-size: 0.57877814em;
}
.katex .sizing.reset-size11.size9,
.katex .fontsize-ensurer.reset-size11.size9 {
  font-size: 0.69453376em;
}
.katex .sizing.reset-size11.size10,
.katex .fontsize-ensurer.reset-size11.size10 {
  font-size: 0.83360129em;
}
.katex .sizing.reset-size11.size11,
.katex .fontsize-ensurer.reset-size11.size11 {
  font-size: 1em;
}
.katex .delimsizing.size1 {
  font-family: KaTeX_Size1;
}
.katex .delimsizing.size2 {
  font-family: KaTeX_Size2;
}
.katex .delimsizing.size3 {
  font-family: KaTeX_Size3;
}
.katex .delimsizing.size4 {
  font-family: KaTeX_Size4;
}
.katex .delimsizing.mult .delim-size1 > span {
  font-family: KaTeX_Size1;
}
.katex .delimsizing.mult .delim-size4 > span {
  font-family: KaTeX_Size4;
}
.katex .nulldelimiter {
  display: inline-block;
  width: 0.12em;
}
.katex .delimcenter {
  position: relative;
}
.katex .op-symbol {
  position: relative;
}
.katex .op-symbol.small-op {
  font-family: KaTeX_Size1;
}
.katex .op-symbol.large-op {
  font-family: KaTeX_Size2;
}
.katex .op-limits > .vlist-t {
  text-align: center;
}
.katex .accent > .vlist-t {
  text-align: center;
}
.katex .accent .accent-body {
  position: relative;
}
.katex .accent .accent-body:not(.accent-full) {
  width: 0;
}
.katex .overlay {
  display: block;
}
.katex .mtable .vertical-separator {
  display: inline-block;
  min-width: 1px;
}
.katex .mtable .arraycolsep {
  display: inline-block;
}
.katex .mtable .col-align-c > .vlist-t {
  text-align: center;
}
.katex .mtable .col-align-l > .vlist-t {
  text-align: left;
}
.katex .mtable .col-align-r > .vlist-t {
  text-align: right;
}
.katex .svg-align {
  text-align: left;
}
.katex svg {
  display: block;
  position: absolute;
  width: 100%;
  height: inherit;
  fill: currentColor;
  stroke: currentColor;
  fill-rule: nonzero;
  fill-opacity: 1;
  stroke-width: 1;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  stroke-miterlimit: 4;
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  stroke-opacity: 1;
}
.katex svg path {
  stroke: none;
}
.katex img {
  border-style: none;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
}
.katex .stretchy {
  width: 100%;
  display: block;
  position: relative;
  overflow: hidden;
}
.katex .stretchy::before,
.katex .stretchy::after {
  content: "";
}
.katex .hide-tail {
  width: 100%;
  position: relative;
  overflow: hidden;
}
.katex .halfarrow-left {
  position: absolute;
  left: 0;
  width: 50.2%;
  overflow: hidden;
}
.katex .halfarrow-right {
  position: absolute;
  right: 0;
  width: 50.2%;
  overflow: hidden;
}
.katex .brace-left {
  position: absolute;
  left: 0;
  width: 25.1%;
  overflow: hidden;
}
.katex .brace-center {
  position: absolute;
  left: 25%;
  width: 50%;
  overflow: hidden;
}
.katex .brace-right {
  position: absolute;
  right: 0;
  width: 25.1%;
  overflow: hidden;
}
.katex .x-arrow-pad {
  padding: 0 0.5em;
}
.katex .x-arrow,
.katex .mover,
.katex .munder {
  text-align: center;
}
.katex .boxpad {
  padding: 0 0.3em 0 0.3em;
}
.katex .fbox,
.katex .fcolorbox {
  box-sizing: border-box;
  border: 0.04em solid;
}
.katex .cancel-pad {
  padding: 0 0.2em 0 0.2em;
}
.katex .cancel-lap {
  margin-left: -0.2em;
  margin-right: -0.2em;
}
.katex .sout {
  border-bottom-style: solid;
  border-bottom-width: 0.08em;
}
.katex-display {
  display: block;
  margin: 1em 0;
  text-align: center;
}
.katex-display > .katex {
  display: block;
  text-align: center;
  white-space: nowrap;
}
.katex-display > .katex > .katex-html {
  display: block;
  position: relative;
}
.katex-display > .katex > .katex-html > .tag {
  position: absolute;
  right: 0;
}
.katex-display.leqno > .katex > .katex-html > .tag {
  left: 0;
  right: auto;
}
.katex-display.fleqn > .katex {
  text-align: left;
  padding-left: 2em;
}
</style><meta http-equiv="origin-trial" content="A+b/H0b8RPXNaJgaNFpO0YOFuGK6myDQXlwnJB3SwzvNMfcndat4DZYMrP4ClJIzYWo3/yP2S+8FTZ/lpqbPAAEAAABueyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzVGhpcmRQYXJ0eSI6dHJ1ZX0="><meta http-equiv="origin-trial" content="A9ZgbRtm4pU3oZiuNzOsKcC8ppFSZdcjP2qYcdQrFKVzkmiWH1kdYY1Mi9x7G8+PS8HV9Ha9Cz0gaMdKsiVZIgMAAAB7eyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="AxL6oBxcpn5rQDPKSAs+d0oxNyJYq2/4esBUh3Yx5z8QfcLu+AU8iFCXYRcr/CEEfDnkxxLTsvXPJFQBxHfvkgMAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A9KPtG5kl3oLTk21xqynDPGQ5t18bSOpwt0w6kGa6dEWbuwjpffmdUpR3W+faZDubGT+KIk2do0BX2ca16x8qAcAAACBeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiVHJ1c3RUb2tlbnMiLCJleHBpcnkiOjE2MjYyMjA3OTksImlzU3ViZG9tYWluIjp0cnVlLCJpc1RoaXJkUGFydHkiOnRydWV9"><meta http-equiv="origin-trial" content="A3HucHUo1oW9s+9kIKz8mLkbcmdaj5lxt3eiIMp1Nh49dkkBlg1Fhg4Fd/r0vL69mRRA36YutI9P/lJUfL8csQoAAACFeyJvcmlnaW4iOiJodHRwczovL2RvdWJsZWNsaWNrLm5ldDo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjI2MjIwNzk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A0OysezhLoCRYomumeYlubLurZTCmsjTb087OvtCy95jNM65cfEsbajrJnhaGwiTxhz38ZZbm+UhUwQuXfVPTg0AAACLeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXN5bmRpY2F0aW9uLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjI2MjIwNzk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="AxoOxdZQmIoA1WeAPDixRAeWDdgs7ZtVFfH2y19ziTgD1iaHE5ZGz2UdSjubkWvob9C5PrjUfkWi4ZSLgWk3Xg8AAACLeyJvcmlnaW4iOiJodHRwczovL2dvb2dsZXRhZ3NlcnZpY2VzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjI2MjIwNzk5LCJpc1N1YmRvbWFpbiI6dHJ1ZSwiaXNUaGlyZFBhcnR5Ijp0cnVlfQ=="><meta http-equiv="origin-trial" content="A7+rMYR5onPnACrz+niKSeFdH3xw1IyHo2AZSHmxrofRk9w4HcQPMYcpBUKu6OQ6zsdxf4m/vqa6tG6Na4OLpAQAAAB4eyJvcmlnaW4iOiJodHRwczovL2ltYXNkay5nb29nbGVhcGlzLmNvbTo0NDMiLCJmZWF0dXJlIjoiQ29udmVyc2lvbk1lYXN1cmVtZW50IiwiZXhwaXJ5IjoxNjI2MjIwNzk5LCJpc1RoaXJkUGFydHkiOnRydWV9"><link rel="preload" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(3).txt" as="script"><script type="text/javascript" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(3).txt"></script><link rel="preload" href="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(3).txt" as="script"><script type="text/javascript" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(3).txt"></script></head>
  <body>
    <div id="root"><div class="d-none d-lg-block text-center"><div id="OA_holder_5" class="ad-container" style="display:none"><div id="beacon_d746f34ad3" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg.php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div></div><div id="root-top-container"></div><nav id="sf-header" class="bg-white shadow-sm sticky-top navbar navbar-expand-lg navbar-light"><div class="container"><a href="https://segmentfault.com/" class="navbar-brand"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/logo-b.d865fc97.svg" width="139" height="26" class="d-inline-block" alt="segmentfault"></a><a class="btn btn-primary d-lg-none ml-auto mr-2" href="https://segmentfault.com/user/login">注册登录</a><button aria-controls="basic-navbar-nav" type="button" aria-label="Toggle navigation" class="navbar-toggler collapsed"><span class="navbar-toggler-icon"></span></button><div class="justify-content-between navbar-collapse collapse" id="basic-navbar-nav"><div class="font-weight-bold navbar-nav"><a href="https://segmentfault.com/" data-rb-event-key="/" class="nav-link">首页</a><a href="https://segmentfault.com/questions" data-rb-event-key="/questions" class="nav-link">问答</a><a href="https://segmentfault.com/blogs" data-rb-event-key="/blogs" class="nav-link">专栏</a><a href="https://segmentfault.com/news" data-rb-event-key="/news" class="nav-link">资讯</a><a href="https://ke.sifou.com/" target="_blank" rel="noreferrer" class="nav-link">课程<i class="ml-1 text-danger fas fa-fire-alt" style="width:0.88rem;vertical-align:text-bottom"></i></a><a href="https://segmentfault.com/events" data-rb-event-key="/events" class="nav-link">活动</a><div class="hover-down nav-item dropdown"><a aria-haspopup="true" aria-expanded="false" id="basic-nav-dropdown" href="https://segmentfault.com/a/1190000039073805#" class="dropdown-toggle nav-link" role="button">发现</a></div></div><form action="https://segmentfault.com/search" class="d-none d-xl-block px-3 header-search___28AtS form-inline"><input type="text" name="q" placeholder="搜索关键字" aria-label="搜索" class="mr-sm-2 w-100 form-control"></form><nav class="p-0 navbar navbar-expand navbar-light"><div class="d-none d-lg-flex mr-2 nav-item"><a href="https://segmentfault.com/user/login" class="btn btn-link">立即登录</a></div><div class="d-none d-lg-flex nav-item"><a href="https://segmentfault.com/user/register" class="btn btn-primary">免费注册</a></div></nav></div></div></nav><div class="d-none d-xl-flex justify-content-center"><div id="OA_holder_2" class="ad-container" style="display:block"><div id="beacon_248e9baaa2" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(1).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div></div><div class="article-content container"><nav aria-label="breadcrumb" class="font-size-14 px-0 my-0 mx-4 mx-md-0"><ol class="breadcrumb bg-transparent"><li class="breadcrumb-item"><a href="https://segmentfault.com/">首页</a></li><li class="breadcrumb-item"><a href="https://segmentfault.com/blogs">专栏</a></li><li class="breadcrumb-item"><a href="https://segmentfault.com/t/java/blogs">java</a></li><li class="breadcrumb-item active" aria-current="page">文章详情</li></ol></nav><div class="row"><div class="col-12 col-xl w-0 col"><div class="sticky-wrap sticky-top functional-area-left d-none d-xl-flex justify-content-center pt-5 functional-area-left2"><div role="group" class="align-items-center btn-group-vertical"><button aria-label="点赞" type="button" class="func-btn mainLike  sflex-center shadow-sm rounded-circle main-lg-Like mb-3 btn btn-outline-primary"><i class="far fa-thumbs-up"></i><span class="mainLikeNum ">2</span></button><button aria-label="收藏" type="button" class="func-btn sflex-center rounded-circle mb-2 btn btn-outline-secondary"><i class="far fa-bookmark"></i></button><a class="func-btn sflex-center btn btn-outline-secondary rounded-circle mb-2" href="https://segmentfault.com/a/1190000039073805#comment-area" aria-label="评论"><i class="far fa-comment-alt-lines"></i></a><div class="dropdown"><a href="https://segmentfault.com/a/1190000039073805#" class="func-btn nav-tab-item  rounded-pill btn btn-outline-secondary sflex-center rounded-circle dropdown-toggle" aria-label="分享"><i class="far fa-share-alt"></i></a></div></div></div><canvas hidden="" class="qrcode" height="116" width="116" style="height: 116px; width: 116px;"></canvas><div class="border-0 mb-4 card"><div class="p-lg-30 position-relative card-body"><h1 class="h2 mb-3"><a href="https://segmentfault.com/a/1190000039073805" class="text-body">Springboot整合quartz实现定时任务的动态加载</a></h1><div class="d-flex align-items-center mb-4"><a href="https://segmentfault.com/u/chaojidaxianyu" class="d-flex align-items-center"><picture class="mr-2 d-sm-block d-none"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/995577583-600d004f5bef7_big64" alt="" class="d-inline-block rounded-circle" width="32"></picture><strong class="align-self-center font-size-14">超级大咸鱼</strong></a><time class="text-secondary font-size-14" datetime="2021-01-24T05:33:24.000Z" itemprop="datePublished" style="margin-left:12px" aria-describedby="top">发布于 <!-- -->1 月 24 日</time></div><div id="OA_holder_25" class="ad-container" style="display:block"><div id="beacon_84f26f99d2" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(2).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div><article class="article fmt article-content "><h1 id="item-1">Springboot整合quartz实现定时任务的动态加载</h1><p>Springboot整合quartz,实现动态定时任务的加载，不需要重启程序，就可以堆定时任务进行添加，停止，删除，重启等一系列操作，通过mysql数据库对定时任务进行配置。</p><h1 id="item-2">目录结构</h1><p><span class="img-wrap"><img class="lazy entered loaded" data-src="https://image-static.segmentfault.com/351/221/3512219754-600d086ca7053" alt="image" title="image" data-ll-status="loaded" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/3512219754-600d086ca7053"></span></p><h1 id="item-3">1.数据库</h1><p>创建数据库配置表，用于存放定时任务的相关配置</p><div class="widget-codetool" style="">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="CREATE TABLE `task_config`  (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  `task_id` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT &#39;任务id&#39;,
  `cron` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT &#39;cron表达式&#39;,
  `class_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT &#39;job引用地址&#39;,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT &#39;描述&#39;,
  `status` tinyint NOT NULL COMMENT &#39;定时任务状态 0 停用,1启用&#39;,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="sql hljs"><code class="mysql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> `task_config`  (
  `id` <span class="hljs-type">int</span> UNSIGNED <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> AUTO_INCREMENT,
  `task_id` <span class="hljs-type">varchar</span>(<span class="hljs-number">8</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8mb4 <span class="hljs-keyword">COLLATE</span> utf8mb4_0900_ai_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">'任务id'</span>,
  `cron` <span class="hljs-type">varchar</span>(<span class="hljs-number">20</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8mb4 <span class="hljs-keyword">COLLATE</span> utf8mb4_0900_ai_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">'cron表达式'</span>,
  `class_name` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8mb4 <span class="hljs-keyword">COLLATE</span> utf8mb4_0900_ai_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">'job引用地址'</span>,
  `description` <span class="hljs-type">varchar</span>(<span class="hljs-number">255</span>) <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> utf8mb4 <span class="hljs-keyword">COLLATE</span> utf8mb4_0900_ai_ci <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">'描述'</span>,
  `status` tinyint <span class="hljs-keyword">NOT</span> <span class="hljs-keyword">NULL</span> COMMENT <span class="hljs-string">'定时任务状态 0 停用,1启用'</span>,
  <span class="hljs-keyword">PRIMARY</span> KEY (`id`) <span class="hljs-keyword">USING</span> BTREE
) ENGINE <span class="hljs-operator">=</span> InnoDB <span class="hljs-type">CHARACTER</span> <span class="hljs-keyword">SET</span> <span class="hljs-operator">=</span> utf8mb4 <span class="hljs-keyword">COLLATE</span> <span class="hljs-operator">=</span> utf8mb4_0900_ai_ci ROW_FORMAT <span class="hljs-operator">=</span> <span class="hljs-keyword">Dynamic</span>;

<span class="hljs-keyword">SET</span> FOREIGN_KEY_CHECKS <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;</code></pre><h1 id="item-4">2.导包</h1><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
        &lt;artifactId&gt;lombok&lt;/artifactId&gt;
        &lt;version&gt;1.16.18&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;!--quartz和springboot的整合包--&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-quartz&lt;/artifactId&gt;
        &lt;version&gt;2.0.4.RELEASE&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!--mybatisPlus可以放我们更方便的操作mybatis--&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.baomidou&lt;/groupId&gt;
        &lt;artifactId&gt;mybatis-plus-boot-starter&lt;/artifactId&gt;
        &lt;version&gt;3.4.0&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;!--数据库连接池框架--&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
        &lt;artifactId&gt;druid&lt;/artifactId&gt;
        &lt;version&gt;1.1.9&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;mysql&lt;/groupId&gt;
        &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
        &lt;version&gt;8.0.17&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="xml hljs"><code class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependencies</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.projectlombok<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>lombok<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>1.16.18<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>provided<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-comment">&lt;!--quartz和springboot的整合包--&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-quartz<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>2.0.4.RELEASE<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-comment">&lt;!--mybatisPlus可以放我们更方便的操作mybatis--&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.baomidou<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mybatis-plus-boot-starter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.4.0<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-comment">&lt;!--数据库连接池框架--&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.alibaba<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>druid<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>1.1.9<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>mysql<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mysql-connector-java<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>8.0.17<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependencies</span>&gt;</span></code></pre><h1 id="item-5">3.Springboot启动配置</h1><h2 id="item-5-1">1.数据源的配置</h2><p><code>application-datasource.yml</code>配置文件</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&amp;useSSL=true&amp;useSSL=false&amp;allowMultiQueries=true&amp;serverTimezone=UTC
    username: root
    password: 123456
    type: com.alibaba.druid.pool.DruidDataSource" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="hljs dts"><code class="yaml"><span class="hljs-symbol">spring:</span>
<span class="hljs-symbol">  datasource:</span>
    driver-class-name: com.mysql.jdbc.Driver
<span class="hljs-symbol">    url:</span> jdbc:mysql:<span class="hljs-comment">//127.0.0.1:3306/test?characterEncoding=utf8&amp;useSSL=true&amp;useSSL=false&amp;allowMultiQueries=true&amp;serverTimezone=UTC</span>
<span class="hljs-symbol">    username:</span> root
<span class="hljs-symbol">    password:</span> <span class="hljs-number">123456</span>
<span class="hljs-symbol">    type:</span> com.alibaba.druid.pool.DruidDataSource</code></pre><p>注：mysql的版本不同，先用<code>driver-class-name</code>也不同，同时<code>mysql8</code>需要配置时区<code>serverTimezone</code></p><h2 id="item-5-2">2.mybatisPlus的配置</h2><p><code>application-mybatis.yml</code>配置文件</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="mybatis-plus:
    #扫描xml的位置
  mapper-locations: classpath*:/dao/*.xml
  configuration:
    # 这个配置会将执行的sql打印出来，在开发或测试的时候可以用
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="hljs elixir"><code class="yaml">mybatis-<span class="hljs-symbol">plus:</span>
    <span class="hljs-comment">#扫描xml的位置</span>
  mapper-<span class="hljs-symbol">locations:</span> classpath*<span class="hljs-symbol">:/dao/*</span>.xml
  <span class="hljs-symbol">configuration:</span>
    <span class="hljs-comment"># 这个配置会将执行的sql打印出来，在开发或测试的时候可以用</span>
    log-<span class="hljs-symbol">impl:</span> org.apache.ibatis.logging.stdout.StdOutImpl</code></pre><h2 id="item-5-3">3.Spring的配置</h2><p><code>application.yml</code>配置文件</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="spring:
  application:
    name: schedule-server
  profiles:
      #配置激活配置文件，application-mybatis，application-datasource
    active: datasource,mybatis
server:
  port: 9000" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="hljs yaml"><code class="yaml"><span class="hljs-attr">spring:</span>
  <span class="hljs-attr">application:</span>
    <span class="hljs-attr">name:</span> <span class="hljs-string">schedule-server</span>
  <span class="hljs-attr">profiles:</span>
      <span class="hljs-comment">#配置激活配置文件，application-mybatis，application-datasource</span>
    <span class="hljs-attr">active:</span> <span class="hljs-string">datasource,mybatis</span>
<span class="hljs-attr">server:</span>
  <span class="hljs-attr">port:</span> <span class="hljs-number">9000</span></code></pre><h1 id="item-6">4.mybatis层</h1><h2 id="item-6-4">1.创建数据库表对应的实体</h2><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

@Data
@Accessors(chain = true)
@TableName(&quot;task_config&quot;)
public class TaskConfigEntity implements Serializable {

    @TableId(value = &quot;id&quot;,type = IdType.AUTO)
    private Integer id;

    @TableField(&quot;task_id&quot;)
    private String taskId;

    @TableField(&quot;cron&quot;)
    private String cron;

    @TableField(&quot;class_name&quot;)
    private String className;

    @TableField(&quot;description&quot;)
    private String description;

    @TableField(&quot;status&quot;)
    private Integer status;
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.IdType;
<span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.TableField;
<span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.TableId;
<span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.TableName;
<span class="hljs-keyword">import</span> lombok.Data;
<span class="hljs-keyword">import</span> lombok.experimental.Accessors;

<span class="hljs-keyword">import</span> java.io.Serializable;

<span class="hljs-meta">@Data</span>
<span class="hljs-meta">@Accessors(chain = true)</span>
<span class="hljs-meta">@TableName("task_config")</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TaskConfigEntity</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Serializable</span> </span>{

    <span class="hljs-meta">@TableId(value = "id",type = IdType.AUTO)</span>
    <span class="hljs-keyword">private</span> Integer id;

    <span class="hljs-meta">@TableField("task_id")</span>
    <span class="hljs-keyword">private</span> String taskId;

    <span class="hljs-meta">@TableField("cron")</span>
    <span class="hljs-keyword">private</span> String cron;

    <span class="hljs-meta">@TableField("class_name")</span>
    <span class="hljs-keyword">private</span> String className;

    <span class="hljs-meta">@TableField("description")</span>
    <span class="hljs-keyword">private</span> String description;

    <span class="hljs-meta">@TableField("status")</span>
    <span class="hljs-keyword">private</span> Integer status;
}</code></pre><h2 id="item-6-5">2.dao接口</h2><p>同时创建dao接口</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.TaskConfigEntity;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface TaskConfigDao extends BaseMapper&lt;TaskConfigEntity&gt; {
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.core.mapper.BaseMapper;
<span class="hljs-keyword">import</span> com.example.demo.entity.TaskConfigEntity;
<span class="hljs-keyword">import</span> org.apache.ibatis.annotations.Mapper;

<span class="hljs-meta">@Mapper</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">TaskConfigDao</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">BaseMapper</span>&lt;<span class="hljs-title">TaskConfigEntity</span>&gt; </span>{
}</code></pre><h2 id="item-6-6">3.xml文件</h2><p>在resource资源包下创建<code>dao\TaskConfigDao.xml</code></p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE mapper PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; &quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot; &gt;
&lt;mapper namespace=&quot;com.example.demo.dao.TaskConfigDao&quot;&gt;

&lt;/mapper&gt;" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="xml hljs"><code class="xml"><span class="hljs-meta">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;</span>
<span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">mapper</span> <span class="hljs-meta-keyword">PUBLIC</span> <span class="hljs-meta-string">"-//mybatis.org//DTD Mapper 3.0//EN"</span> <span class="hljs-meta-string">"http://mybatis.org/dtd/mybatis-3-mapper.dtd"</span> &gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">mapper</span> <span class="hljs-attr">namespace</span>=<span class="hljs-string">"com.example.demo.dao.TaskConfigDao"</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">mapper</span>&gt;</span></code></pre><h2 id="item-6-7">4.扫描dao接口</h2><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
//扫描路径
@MapperScan(&quot;com.example.demo.dao&quot;)
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo;

<span class="hljs-keyword">import</span> org.mybatis.spring.annotation.MapperScan;
<span class="hljs-keyword">import</span> org.springframework.boot.SpringApplication;
<span class="hljs-keyword">import</span> org.springframework.boot.autoconfigure.SpringBootApplication;

<span class="hljs-meta">@SpringBootApplication</span>
<span class="hljs-comment">//扫描路径</span>
<span class="hljs-meta">@MapperScan("com.example.demo.dao")</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DemoApplication</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        SpringApplication.run(DemoApplication.class, args);
    }

}</code></pre><h1 id="item-7">5.线程池的创建</h1><p>创建线程池用于运行定时任务</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ExecutorConfig {
    @Bean(name = &quot;taskExecutor&quot;)
    public Executor getAsyncExecutor() throws InterruptedException{
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(1024);
        executor.setKeepAliveSeconds(4);
        executor.setQueueCapacity(0);
        executor.setRejectedExecutionHandler((Runnable r, ThreadPoolExecutor exe) -&gt; {
            // 利用BlockingQueue的特性，任务队列满时等待放入
            try {
                if (!exe.getQueue().offer(r, 30, TimeUnit.SECONDS)) {
                    throw new Exception(&quot;Task offer failed after 30 sec&quot;);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        return executor;
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.config;

<span class="hljs-keyword">import</span> org.springframework.context.annotation.Bean;
<span class="hljs-keyword">import</span> org.springframework.context.annotation.Configuration;
<span class="hljs-keyword">import</span> org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

<span class="hljs-keyword">import</span> java.util.concurrent.Executor;
<span class="hljs-keyword">import</span> java.util.concurrent.ThreadPoolExecutor;
<span class="hljs-keyword">import</span> java.util.concurrent.TimeUnit;

<span class="hljs-meta">@Configuration</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ExecutorConfig</span> </span>{
    <span class="hljs-meta">@Bean(name = "taskExecutor")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Executor <span class="hljs-title">getAsyncExecutor</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> InterruptedException</span>{
        ThreadPoolTaskExecutor executor = <span class="hljs-keyword">new</span> ThreadPoolTaskExecutor();
        executor.setCorePoolSize(<span class="hljs-number">2</span>);
        executor.setMaxPoolSize(<span class="hljs-number">1024</span>);
        executor.setKeepAliveSeconds(<span class="hljs-number">4</span>);
        executor.setQueueCapacity(<span class="hljs-number">0</span>);
        executor.setRejectedExecutionHandler((Runnable r, ThreadPoolExecutor exe) -&gt; {
            <span class="hljs-comment">// 利用BlockingQueue的特性，任务队列满时等待放入</span>
            <span class="hljs-keyword">try</span> {
                <span class="hljs-keyword">if</span> (!exe.getQueue().offer(r, <span class="hljs-number">30</span>, TimeUnit.SECONDS)) {
                    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Exception(<span class="hljs-string">"Task offer failed after 30 sec"</span>);
                }
            } <span class="hljs-keyword">catch</span> (Exception e) {
                e.printStackTrace();
            }
        });
        <span class="hljs-keyword">return</span> executor;
    }
}</code></pre><h1 id="item-8">6.quartz相关配置</h1><h2 id="item-8-8">1.自动注入工厂创建</h2><p>​    注：只有有这个配置，quartz才可以使用自动注入，不然quartz无法使用Autowired等。</p><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.factory;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
import org.springframework.stereotype.Component;

/**
 * 当配置这个config后,quartz才可以使用autowired注入
 */
@Component
public class ScheduleAutoBeanFactory extends SpringBeanJobFactory implements ApplicationContextAware {
    private transient AutowireCapableBeanFactory beanFactory;
    @Override
    public void setApplicationContext(final ApplicationContext context) {
        beanFactory = context.getAutowireCapableBeanFactory();
    }
    @Override
    protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
        final Object job = super.createJobInstance(bundle);
        beanFactory.autowireBean(job);
        return job;
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.factory;

<span class="hljs-keyword">import</span> org.quartz.spi.TriggerFiredBundle;
<span class="hljs-keyword">import</span> org.springframework.beans.factory.config.AutowireCapableBeanFactory;
<span class="hljs-keyword">import</span> org.springframework.context.ApplicationContext;
<span class="hljs-keyword">import</span> org.springframework.context.ApplicationContextAware;
<span class="hljs-keyword">import</span> org.springframework.scheduling.quartz.SpringBeanJobFactory;
<span class="hljs-keyword">import</span> org.springframework.stereotype.Component;

<span class="hljs-comment">/**
 * 当配置这个config后,quartz才可以使用autowired注入
 */</span>
<span class="hljs-meta">@Component</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScheduleAutoBeanFactory</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">SpringBeanJobFactory</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">ApplicationContextAware</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">transient</span> AutowireCapableBeanFactory beanFactory;
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">setApplicationContext</span><span class="hljs-params">(<span class="hljs-keyword">final</span> ApplicationContext context)</span> </span>{
        beanFactory = context.getAutowireCapableBeanFactory();
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">protected</span> Object <span class="hljs-title">createJobInstance</span><span class="hljs-params">(<span class="hljs-keyword">final</span> TriggerFiredBundle bundle)</span> <span class="hljs-keyword">throws</span> Exception </span>{
        <span class="hljs-keyword">final</span> Object job = <span class="hljs-keyword">super</span>.createJobInstance(bundle);
        beanFactory.autowireBean(job);
        <span class="hljs-keyword">return</span> job;
    }
}</code></pre><h1 id="item-9">2.quartz配置</h1><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.config;

import org.quartz.Scheduler;
import org.quartz.spi.JobFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.annotation.Resource;
import java.util.concurrent.Executor;

@Configuration
public class ScheduleJobConfig {
    
    @Resource(name = &quot;taskExecutor&quot;)
    private Executor taskExecutor;

    @Bean(&quot;schedulerFactoryBean&quot;)
    public SchedulerFactoryBean createFactoryBean(JobFactory jobFactory){
        SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
        factoryBean.setJobFactory(jobFactory);
        factoryBean.setTaskExecutor(taskExecutor);
        factoryBean.setOverwriteExistingJobs(true);
        return factoryBean;
    }
    //通过这个类对定时任务进行操作
    @Bean
    public Scheduler scheduler(@Qualifier(&quot;schedulerFactoryBean&quot;) SchedulerFactoryBean factoryBean) {
        return factoryBean.getScheduler();
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.config;

<span class="hljs-keyword">import</span> org.quartz.Scheduler;
<span class="hljs-keyword">import</span> org.quartz.spi.JobFactory;
<span class="hljs-keyword">import</span> org.springframework.beans.factory.annotation.Qualifier;
<span class="hljs-keyword">import</span> org.springframework.context.annotation.Bean;
<span class="hljs-keyword">import</span> org.springframework.context.annotation.Configuration;
<span class="hljs-keyword">import</span> org.springframework.scheduling.quartz.SchedulerFactoryBean;

<span class="hljs-keyword">import</span> javax.annotation.Resource;
<span class="hljs-keyword">import</span> java.util.concurrent.Executor;

<span class="hljs-meta">@Configuration</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScheduleJobConfig</span> </span>{
    
    <span class="hljs-meta">@Resource(name = "taskExecutor")</span>
    <span class="hljs-keyword">private</span> Executor taskExecutor;

    <span class="hljs-meta">@Bean("schedulerFactoryBean")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> SchedulerFactoryBean <span class="hljs-title">createFactoryBean</span><span class="hljs-params">(JobFactory jobFactory)</span></span>{
        SchedulerFactoryBean factoryBean = <span class="hljs-keyword">new</span> SchedulerFactoryBean();
        factoryBean.setJobFactory(jobFactory);
        factoryBean.setTaskExecutor(taskExecutor);
        factoryBean.setOverwriteExistingJobs(<span class="hljs-keyword">true</span>);
        <span class="hljs-keyword">return</span> factoryBean;
    }
    <span class="hljs-comment">//通过这个类对定时任务进行操作</span>
    <span class="hljs-meta">@Bean</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Scheduler <span class="hljs-title">scheduler</span><span class="hljs-params">(<span class="hljs-meta">@Qualifier("schedulerFactoryBean")</span> SchedulerFactoryBean factoryBean)</span> </span>{
        <span class="hljs-keyword">return</span> factoryBean.getScheduler();
    }
}</code></pre><h1 id="item-10">7.quartz功能的实现</h1><h2 id="item-10-9">1.基本功能</h2><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.dao.TaskConfigDao;
import com.example.demo.entity.TaskConfigEntity;
import lombok.extern.log4j.Log4j2;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Log4j2
public class ScheduleJobService {

    @Autowired
    private TaskConfigDao taskConfigDao;

    @Autowired
    private Scheduler scheduler;

    /**
     * 程序启动开始加载定时任务
     */
    public void startJob(){
        List&lt;TaskConfigEntity&gt; taskConfigEntities = taskConfigDao.selectList(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getStatus, 1));
        if (taskConfigEntities == null || taskConfigEntities.size() == 0){
            log.error(&quot;定时任务加载数据为空&quot;);
            return;
        }
        for (TaskConfigEntity configEntity : taskConfigEntities) {
            CronTrigger cronTrigger = null;
            JobDetail jobDetail = null;
            try {
                cronTrigger = getCronTrigger(configEntity);
                jobDetail = getJobDetail(configEntity);
                scheduler.scheduleJob(jobDetail,cronTrigger);
                log.info(&quot;编号：{}定时任务加载成功&quot;,configEntity.getTaskId());
            }catch (Exception e){
                log.error(&quot;编号：{}定时任务加载失败&quot;,configEntity.getTaskId());
            }

        }
        try {
            scheduler.start();
        } catch (SchedulerException e) {
            log.error(&quot;定时任务启动失败&quot;,e);
        }
    }

    /**
     * 停止任务
     * @param taskId
     */
    public void stopJob(String taskId) throws SchedulerException {
        scheduler.pauseJob(JobKey.jobKey(taskId));
    }

    /**
     * 恢复任务
     * @param taskId
     * @throws SchedulerException
     */
    public void resumeJob(String taskId) throws SchedulerException {
        scheduler.resumeJob(JobKey.jobKey(taskId));
    }

    /**
     * 添加新的job
     * @param taskId
     * @throws SchedulerConfigException
     */
    public void loadJob(String taskId) throws SchedulerConfigException {
        TaskConfigEntity taskConfigEntity = taskConfigDao.selectOne(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getTaskId, taskId)
                        .eq(TaskConfigEntity::getStatus, 1));
        if (taskConfigEntity == null){
            throw new SchedulerConfigException(&quot;未找到相关Job配置&quot;);
        }
        try {
            JobDetail jobDetail = getJobDetail(taskConfigEntity);
            CronTrigger cronTrigger = getCronTrigger(taskConfigEntity);
            scheduler.scheduleJob(jobDetail, cronTrigger);
        } catch (Exception e) {
            log.error(&quot;加载定时任务异常&quot;,e);
            throw new SchedulerConfigException(&quot;加载定时任务异常&quot;, e);
        }
    }
    public void unloadJob(String taskId) throws SchedulerException {
        // 停止触发器
        scheduler.pauseTrigger(TriggerKey.triggerKey(taskId));
        // 卸载定时任务
        scheduler.unscheduleJob(TriggerKey.triggerKey(taskId));
        // 删除原来的job
        scheduler.deleteJob(JobKey.jobKey(taskId));
    }

    /**
     * 重新加载执行计划
     * @throws Exception
     */
    public void reload(String taskId) throws Exception {
        TaskConfigEntity taskConfigEntity = taskConfigDao.selectOne(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getTaskId, taskId)
                        .eq(TaskConfigEntity::getStatus, 1));

        String jobCode = taskConfigEntity.getTaskId();
        // 获取以前的触发器
        TriggerKey triggerKey = TriggerKey.triggerKey(jobCode);
        // 停止触发器
        scheduler.pauseTrigger(triggerKey);
        // 删除触发器
        scheduler.unscheduleJob(triggerKey);
        // 删除原来的job
        scheduler.deleteJob(JobKey.jobKey(jobCode));

        JobDetail jobDetail = getJobDetail(taskConfigEntity);
        CronTrigger cronTrigger = getCronTrigger(taskConfigEntity);
        // 重新加载job
        scheduler.scheduleJob(jobDetail, cronTrigger);
    }
    //组装JobDetail
    private JobDetail getJobDetail(TaskConfigEntity configEntity) throws ClassNotFoundException {

        Class&lt;? extends Job&gt; aClass = Class.forName(configEntity.getClassName()).asSubclass(Job.class);

        return JobBuilder.newJob()
                .withIdentity(JobKey.jobKey(configEntity.getTaskId()))
                .withDescription(configEntity.getDescription())
                .ofType(aClass).build();
    }
    //组装CronTrigger
    private CronTrigger getCronTrigger(TaskConfigEntity configEntity){
        CronTrigger cronTrigger = null;
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(configEntity.getCron());
        cronTrigger = TriggerBuilder.newTrigger()
                .withIdentity(TriggerKey.triggerKey(configEntity.getTaskId()))
                .withSchedule(cronScheduleBuilder)
                .build();
        return cronTrigger;
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.service;

<span class="hljs-keyword">import</span> com.baomidou.mybatisplus.core.toolkit.Wrappers;
<span class="hljs-keyword">import</span> com.example.demo.dao.TaskConfigDao;
<span class="hljs-keyword">import</span> com.example.demo.entity.TaskConfigEntity;
<span class="hljs-keyword">import</span> lombok.extern.log4j.Log4j2;
<span class="hljs-keyword">import</span> org.quartz.*;
<span class="hljs-keyword">import</span> org.springframework.beans.factory.annotation.Autowired;
<span class="hljs-keyword">import</span> org.springframework.stereotype.Component;

<span class="hljs-keyword">import</span> java.util.List;

<span class="hljs-meta">@Component</span>
<span class="hljs-meta">@Log4j2</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScheduleJobService</span> </span>{

    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">private</span> TaskConfigDao taskConfigDao;

    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">private</span> Scheduler scheduler;

    <span class="hljs-comment">/**
     * 程序启动开始加载定时任务
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">startJob</span><span class="hljs-params">()</span></span>{
        List&lt;TaskConfigEntity&gt; taskConfigEntities = taskConfigDao.selectList(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getStatus, <span class="hljs-number">1</span>));
        <span class="hljs-keyword">if</span> (taskConfigEntities == <span class="hljs-keyword">null</span> || taskConfigEntities.size() == <span class="hljs-number">0</span>){
            log.error(<span class="hljs-string">"定时任务加载数据为空"</span>);
            <span class="hljs-keyword">return</span>;
        }
        <span class="hljs-keyword">for</span> (TaskConfigEntity configEntity : taskConfigEntities) {
            CronTrigger cronTrigger = <span class="hljs-keyword">null</span>;
            JobDetail jobDetail = <span class="hljs-keyword">null</span>;
            <span class="hljs-keyword">try</span> {
                cronTrigger = getCronTrigger(configEntity);
                jobDetail = getJobDetail(configEntity);
                scheduler.scheduleJob(jobDetail,cronTrigger);
                log.info(<span class="hljs-string">"编号：{}定时任务加载成功"</span>,configEntity.getTaskId());
            }<span class="hljs-keyword">catch</span> (Exception e){
                log.error(<span class="hljs-string">"编号：{}定时任务加载失败"</span>,configEntity.getTaskId());
            }

        }
        <span class="hljs-keyword">try</span> {
            scheduler.start();
        } <span class="hljs-keyword">catch</span> (SchedulerException e) {
            log.error(<span class="hljs-string">"定时任务启动失败"</span>,e);
        }
    }

    <span class="hljs-comment">/**
     * 停止任务
     * <span class="hljs-doctag">@param</span> taskId
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">stopJob</span><span class="hljs-params">(String taskId)</span> <span class="hljs-keyword">throws</span> SchedulerException </span>{
        scheduler.pauseJob(JobKey.jobKey(taskId));
    }

    <span class="hljs-comment">/**
     * 恢复任务
     * <span class="hljs-doctag">@param</span> taskId
     * <span class="hljs-doctag">@throws</span> SchedulerException
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">resumeJob</span><span class="hljs-params">(String taskId)</span> <span class="hljs-keyword">throws</span> SchedulerException </span>{
        scheduler.resumeJob(JobKey.jobKey(taskId));
    }

    <span class="hljs-comment">/**
     * 添加新的job
     * <span class="hljs-doctag">@param</span> taskId
     * <span class="hljs-doctag">@throws</span> SchedulerConfigException
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">loadJob</span><span class="hljs-params">(String taskId)</span> <span class="hljs-keyword">throws</span> SchedulerConfigException </span>{
        TaskConfigEntity taskConfigEntity = taskConfigDao.selectOne(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getTaskId, taskId)
                        .eq(TaskConfigEntity::getStatus, <span class="hljs-number">1</span>));
        <span class="hljs-keyword">if</span> (taskConfigEntity == <span class="hljs-keyword">null</span>){
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> SchedulerConfigException(<span class="hljs-string">"未找到相关Job配置"</span>);
        }
        <span class="hljs-keyword">try</span> {
            JobDetail jobDetail = getJobDetail(taskConfigEntity);
            CronTrigger cronTrigger = getCronTrigger(taskConfigEntity);
            scheduler.scheduleJob(jobDetail, cronTrigger);
        } <span class="hljs-keyword">catch</span> (Exception e) {
            log.error(<span class="hljs-string">"加载定时任务异常"</span>,e);
            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> SchedulerConfigException(<span class="hljs-string">"加载定时任务异常"</span>, e);
        }
    }
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">unloadJob</span><span class="hljs-params">(String taskId)</span> <span class="hljs-keyword">throws</span> SchedulerException </span>{
        <span class="hljs-comment">// 停止触发器</span>
        scheduler.pauseTrigger(TriggerKey.triggerKey(taskId));
        <span class="hljs-comment">// 卸载定时任务</span>
        scheduler.unscheduleJob(TriggerKey.triggerKey(taskId));
        <span class="hljs-comment">// 删除原来的job</span>
        scheduler.deleteJob(JobKey.jobKey(taskId));
    }

    <span class="hljs-comment">/**
     * 重新加载执行计划
     * <span class="hljs-doctag">@throws</span> Exception
     */</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">reload</span><span class="hljs-params">(String taskId)</span> <span class="hljs-keyword">throws</span> Exception </span>{
        TaskConfigEntity taskConfigEntity = taskConfigDao.selectOne(
                Wrappers.&lt;TaskConfigEntity&gt;lambdaQuery()
                        .eq(TaskConfigEntity::getTaskId, taskId)
                        .eq(TaskConfigEntity::getStatus, <span class="hljs-number">1</span>));

        String jobCode = taskConfigEntity.getTaskId();
        <span class="hljs-comment">// 获取以前的触发器</span>
        TriggerKey triggerKey = TriggerKey.triggerKey(jobCode);
        <span class="hljs-comment">// 停止触发器</span>
        scheduler.pauseTrigger(triggerKey);
        <span class="hljs-comment">// 删除触发器</span>
        scheduler.unscheduleJob(triggerKey);
        <span class="hljs-comment">// 删除原来的job</span>
        scheduler.deleteJob(JobKey.jobKey(jobCode));

        JobDetail jobDetail = getJobDetail(taskConfigEntity);
        CronTrigger cronTrigger = getCronTrigger(taskConfigEntity);
        <span class="hljs-comment">// 重新加载job</span>
        scheduler.scheduleJob(jobDetail, cronTrigger);
    }
    <span class="hljs-comment">//组装JobDetail</span>
    <span class="hljs-function"><span class="hljs-keyword">private</span> JobDetail <span class="hljs-title">getJobDetail</span><span class="hljs-params">(TaskConfigEntity configEntity)</span> <span class="hljs-keyword">throws</span> ClassNotFoundException </span>{

        Class&lt;? extends Job&gt; aClass = Class.forName(configEntity.getClassName()).asSubclass(Job.class);

        <span class="hljs-keyword">return</span> JobBuilder.newJob()
                .withIdentity(JobKey.jobKey(configEntity.getTaskId()))
                .withDescription(configEntity.getDescription())
                .ofType(aClass).build();
    }
    <span class="hljs-comment">//组装CronTrigger</span>
    <span class="hljs-function"><span class="hljs-keyword">private</span> CronTrigger <span class="hljs-title">getCronTrigger</span><span class="hljs-params">(TaskConfigEntity configEntity)</span></span>{
        CronTrigger cronTrigger = <span class="hljs-keyword">null</span>;
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(configEntity.getCron());
        cronTrigger = TriggerBuilder.newTrigger()
                .withIdentity(TriggerKey.triggerKey(configEntity.getTaskId()))
                .withSchedule(cronScheduleBuilder)
                .build();
        <span class="hljs-keyword">return</span> cronTrigger;
    }
}</code></pre><h2 id="item-10-10">2.任务启动自动加载定时任务</h2><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.listener;

import com.example.demo.service.ScheduleJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 监听容器启动,并开始从数据库加载定时任务
 */
@Component
public class ScheduleJobInitListener implements CommandLineRunner {

    @Autowired
    private ScheduleJobService jobService;

    @Override
    public void run(String... strings) throws Exception {
        jobService.startJob();
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.listener;

<span class="hljs-keyword">import</span> com.example.demo.service.ScheduleJobService;
<span class="hljs-keyword">import</span> org.springframework.beans.factory.annotation.Autowired;
<span class="hljs-keyword">import</span> org.springframework.boot.CommandLineRunner;
<span class="hljs-keyword">import</span> org.springframework.stereotype.Component;

<span class="hljs-comment">/**
 * 监听容器启动,并开始从数据库加载定时任务
 */</span>
<span class="hljs-meta">@Component</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScheduleJobInitListener</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">CommandLineRunner</span> </span>{

    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">private</span> ScheduleJobService jobService;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span><span class="hljs-params">(String... strings)</span> <span class="hljs-keyword">throws</span> Exception </span>{
        jobService.startJob();
    }
}</code></pre><h2 id="item-10-11">3.通过远程请求加载定时任务</h2><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.controller;

import com.example.demo.service.ScheduleJobService;
import org.quartz.SchedulerConfigException;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ScheduleJobController {
    @Autowired
    private ScheduleJobService jobService;

    @GetMapping(&quot;/load/{taskId}&quot;)
    public String loadJob(@PathVariable(&quot;taskId&quot;) String taskId){
        try {
            jobService.loadJob(taskId);
        } catch (SchedulerConfigException e) {
            return &quot;导入定时任务失败&quot;;
        }
        return &quot;成功&quot;;
    }
    @GetMapping(&quot;/resume/{taskId}&quot;)
    public String resumeJob(@PathVariable(&quot;taskId&quot;) String taskId){
        try {
            jobService.resumeJob(taskId);
        }catch (SchedulerException e) {
            return &quot;恢复定时任务失败&quot;;
        }
        return &quot;成功&quot;;
    }
    @GetMapping(&quot;/stop/{taskId}&quot;)
    public String stopJob(@PathVariable(&quot;taskId&quot;) String taskId){
        try {
            jobService.stopJob(taskId);
        }catch (SchedulerException e) {
            return &quot;暂停定时任务失败&quot;;
        }
        return &quot;成功&quot;;
    }
    @GetMapping(&quot;/unload/{taskId}&quot;)
    public String unloadJob(@PathVariable(&quot;taskId&quot;) String taskId){
        try {
            jobService.unloadJob(taskId);
        }catch (SchedulerException e) {
            return &quot;卸载定时任务失败&quot;;
        }
        return &quot;成功&quot;;
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.controller;

<span class="hljs-keyword">import</span> com.example.demo.service.ScheduleJobService;
<span class="hljs-keyword">import</span> org.quartz.SchedulerConfigException;
<span class="hljs-keyword">import</span> org.quartz.SchedulerException;
<span class="hljs-keyword">import</span> org.springframework.beans.factory.annotation.Autowired;
<span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.GetMapping;
<span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.PathVariable;
<span class="hljs-keyword">import</span> org.springframework.web.bind.annotation.RestController;

<span class="hljs-meta">@RestController</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ScheduleJobController</span> </span>{
    <span class="hljs-meta">@Autowired</span>
    <span class="hljs-keyword">private</span> ScheduleJobService jobService;

    <span class="hljs-meta">@GetMapping("/load/{taskId}")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">loadJob</span><span class="hljs-params">(<span class="hljs-meta">@PathVariable("taskId")</span> String taskId)</span></span>{
        <span class="hljs-keyword">try</span> {
            jobService.loadJob(taskId);
        } <span class="hljs-keyword">catch</span> (SchedulerConfigException e) {
            <span class="hljs-keyword">return</span> <span class="hljs-string">"导入定时任务失败"</span>;
        }
        <span class="hljs-keyword">return</span> <span class="hljs-string">"成功"</span>;
    }
    <span class="hljs-meta">@GetMapping("/resume/{taskId}")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">resumeJob</span><span class="hljs-params">(<span class="hljs-meta">@PathVariable("taskId")</span> String taskId)</span></span>{
        <span class="hljs-keyword">try</span> {
            jobService.resumeJob(taskId);
        }<span class="hljs-keyword">catch</span> (SchedulerException e) {
            <span class="hljs-keyword">return</span> <span class="hljs-string">"恢复定时任务失败"</span>;
        }
        <span class="hljs-keyword">return</span> <span class="hljs-string">"成功"</span>;
    }
    <span class="hljs-meta">@GetMapping("/stop/{taskId}")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">stopJob</span><span class="hljs-params">(<span class="hljs-meta">@PathVariable("taskId")</span> String taskId)</span></span>{
        <span class="hljs-keyword">try</span> {
            jobService.stopJob(taskId);
        }<span class="hljs-keyword">catch</span> (SchedulerException e) {
            <span class="hljs-keyword">return</span> <span class="hljs-string">"暂停定时任务失败"</span>;
        }
        <span class="hljs-keyword">return</span> <span class="hljs-string">"成功"</span>;
    }
    <span class="hljs-meta">@GetMapping("/unload/{taskId}")</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">unloadJob</span><span class="hljs-params">(<span class="hljs-meta">@PathVariable("taskId")</span> String taskId)</span></span>{
        <span class="hljs-keyword">try</span> {
            jobService.unloadJob(taskId);
        }<span class="hljs-keyword">catch</span> (SchedulerException e) {
            <span class="hljs-keyword">return</span> <span class="hljs-string">"卸载定时任务失败"</span>;
        }
        <span class="hljs-keyword">return</span> <span class="hljs-string">"成功"</span>;
    }
}</code></pre><h1 id="item-11">8.定时任务</h1><div class="widget-codetool" style="display: none;">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="package com.example.demo.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class MyJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(&quot;定时任务开始&quot;+now.format(DateTimeFormatter.ofPattern(&quot;HH:mm:ss&quot;)));
    }
}" title="" data-original-title="复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java"><span class="hljs-keyword">package</span> com.example.demo.job;

<span class="hljs-keyword">import</span> org.quartz.Job;
<span class="hljs-keyword">import</span> org.quartz.JobExecutionContext;
<span class="hljs-keyword">import</span> org.quartz.JobExecutionException;

<span class="hljs-keyword">import</span> java.time.LocalDateTime;
<span class="hljs-keyword">import</span> java.time.format.DateTimeFormatter;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyJob</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">Job</span> </span>{
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">execute</span><span class="hljs-params">(JobExecutionContext jobExecutionContext)</span> <span class="hljs-keyword">throws</span> JobExecutionException </span>{
        LocalDateTime now = LocalDateTime.now();
        System.out.println(<span class="hljs-string">"定时任务开始"</span>+now.format(DateTimeFormatter.ofPattern(<span class="hljs-string">"HH:mm:ss"</span>)));
    }
}</code></pre><p>通过实现Job接口，然后配置到数据库，就可以实现动态加载。</p><h1 id="item-12">9.测试</h1><h2 id="item-12-12">1.向数据库插入一条定时任务的配置。</h2><p>其中class_name为我们实现的Job的引用路径</p><div class="widget-codetool" style="">
        <div class="widget-codetool--inner">
        <button type="button" class="btn btn-dark far fa-copy rounded-0 sflex-center copyCode" data-toggle="tooltip" data-placement="top" data-clipboard-text="INSERT INTO `test`.`task_config` (`id`, `task_id`, `cron`, `class_name`, `description`, `status`) VALUES (&#39;1&#39;, &#39;TB00001&#39;, &#39;0 * * * * ?&#39;, &#39;com.example.demo.job.MyJob&#39;, &#39;每一分钟触发一次&#39;, &#39;1&#39;);
" title="" data-original-title="已复制"></button>
        </div>
        </div><pre class="java hljs"><code class="java">INSERT INTO `test`.`task_config` (`id`, `task_id`, `cron`, `class_name`, `description`, `status`) VALUES (<span class="hljs-string">'1'</span>, <span class="hljs-string">'TB00001'</span>, <span class="hljs-string">'0 * * * * ?'</span>, <span class="hljs-string">'com.example.demo.job.MyJob'</span>, <span class="hljs-string">'每一分钟触发一次'</span>, <span class="hljs-string">'1'</span>);
</code></pre><h2 id="item-12-13">2.启动框架</h2><p><span class="img-wrap"><img class="lazy entered loaded" data-src="https://image-static.segmentfault.com/118/710/1187104227-600d088e7d66b" alt="image" title="image" data-ll-status="loaded" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/1187104227-600d088e7d66b"></span></p><p>我配置的是一分钟执行一次<br><span class="img-wrap"><img class="lazy entered loaded" data-src="https://image-static.segmentfault.com/236/929/2369292309-600d08a4d56bf" alt="image" title="image" data-ll-status="loaded" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/2369292309-600d08a4d56bf"></span></p><h2 id="item-12-14">3.通过网络请求</h2><p>可以通过浏览器访问地址，操作定时任务。</p><p><span class="img-wrap"><img class="lazy entered loaded" data-src="https://image-static.segmentfault.com/353/298/3532988909-600d08b281ced" alt="image" title="image" data-ll-status="loaded" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/3532988909-600d08b281ced"></span></p><p><span class="img-wrap"><img class="lazy entered loaded exited" data-src="https://image-static.segmentfault.com/423/762/4237620685-600d08c5ccc6d" alt="image" title="image" data-ll-status="loaded" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/4237620685-600d08c5ccc6d"></span></p></article><div class="d-flex flex-wrap align-items-center "><div class="m-n1"><a href="https://segmentfault.com/t/java" class="m-1 badge-tag">java</a><a href="https://segmentfault.com/t/springboot" class="m-1 badge-tag">springboot</a><a href="https://segmentfault.com/t/quartz" class="m-1 badge-tag">quartz</a><a href="https://segmentfault.com/t/mysql" class="m-1 badge-tag">mysql</a></div></div><div class="my-4"><div id="OA_holder_3" class="ad-container" style="display:block"><div class="d-none d-lg-flex justify-content-center">
<script async="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(2).txt"></script>
<!-- 中部横幅广告位 -->
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-6330872677300335" data-ad-slot="5598290435" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_0_anchor" style="display:block;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent;"><iframe id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;border:0;width:728px;height:90px;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="728" height="90" frameborder="0" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/ads.html" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!1" data-google-query-id="CP_9_p-jxe8CFQipvQodwTcECw" data-load-complete="true"></iframe></ins></ins></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><div id="beacon_4aee92544c" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(3).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div></div>
</div></div><div class="text-secondary font-size-14 mt-3 mb-5 d-flex justify-content-between row"><div class="col"><span>阅读 <!-- -->381</span><span class="split-dot"></span><time datetime="2021-01-24T05:33:24.000Z" itemprop="datePublished">更新于 <!-- -->1 月 24 日</time></div><div class="operation col-6 text-right col-xs-3 col"><div></div></div></div><div class="functional-area-bottom text-center"><div role="group" class="btn-group like-group align-items-center btn-group"><button type="button" class="btn mr-2 rounded btn btn-outline-primary"><i class="far fa-thumbs-up"></i><span class="ml-1">赞</span><span class="mainLikeNum ml-1">2</span></button><button type="button" class="btn mr-2 rounded btn btn-outline-secondary"><i class="far fa-bookmark"></i><span class="ml-1">收藏</span><span class="ml-1">1</span></button><div class="bottom-share-wrap dropdown"><a href="https://segmentfault.com/a/1190000039073805#" class="nav-tab-item  btn d-flex justify-content-center align-items-center dropdown-toggle" aria-label="分享"><button type="button" class="btn rounded btn btn-outline-secondary"><i class="far fa-share-alt"></i><span class="ml-1">分享</span></button></a></div></div></div><canvas hidden="" class="qrcode"></canvas><div class="font-size-14 text-secondary text-center mt-3 mb-5"><span>本作品系原创，</span><a target="_blank" rel="noreferrer" class="text-secondary" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">采用《署名-非商业性使用-禁止演绎 4.0 国际》许可协议</a></div></div></div><div class="d-block d-xl-none mt-sm-4"><div class="mb-4 border-0 card"><div class="card-body"><div class="d-flex align-items-center mb-3"><picture class="rounded-circle mr-3"><a href="https://segmentfault.com/u/chaojidaxianyu"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/995577583-600d004f5bef7_big64" alt="avatar" width="64" height="64" class="rounded-circle"></a></picture><div><h5 class="mb-0"><a href="https://segmentfault.com/u/chaojidaxianyu" class="text-body">超级大咸鱼</a></h5></div></div><div class="text-secondary text-truncate-2 userExcerpt mb-3"><p>当学Java的菜鸟</p></div><div class="d-flex align-items-center mb-3"><div class="mr-4"><strong>9</strong><span class="text-secondary"> 声望</span></div><div><strong>1</strong><span class="text-secondary"> 粉丝</span></div></div><button type="button" class="btn btn-primary btn-block">关注作者</button></div></div></div><div id="comment-area"><div class="d-flex justify-content-between mb-2 px-4 px-md-0"><div id="comment-total" class="h5 mb-0">2<!-- --> 条评论</div><div><a href="https://segmentfault.com/a/1190000039073805#" class="sort text-dark">得票</a><span class="split-dot text-secondary"></span><a href="https://segmentfault.com/a/1190000039073805#" class="sort text-secondary">时间</a></div></div><div class="comment-wrap border-0  card"><div class="card-body"><div class="mb-4 media"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/3179314346-5f61e47221e07" class="rounded-circle mr-3" width="38" aria-hidden="true"><div class="media-body"><div class="form-group"><textarea rows="1" placeholder="撰写评论 …" aria-label="评论" class="comment-text form-control" style="overflow: hidden; overflow-wrap: break-word; resize: none; height: 38px;" data-tribute="true"></textarea><div class="invalid-feedback"></div></div><div class="d-flex justify-content-end align-items-center"><a href="https://segmentfault.com/a/1190000039073805#" class="mr-3" aria-label="提示"><i class="far fa-info-circle text-secondary"></i></a><button disabled="" type="button" class="float-right btn btn-primary">提交评论</button></div></div></div><div class="comment-body-wrap false"><div class="mb-r d-flex align-items-start false media"><img class="d-block rounded-circle mr-3" width="38" height="38" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/3442544781-5bcbc2e381137_big64" alt=""><div class="w-0  media-body"><div class="commentUnit "><div class="mb-1"><a class="d-uname" href="https://segmentfault.com/u/sunxiaozhi" rel="noreferrer" target="_blank"><strong>孙小智</strong></a>：<div class="parsedText fmt"><p>你好，有源码地址吗？</p></div></div><div class="handle-bar font-size-14 d-flex justify-content-between"><div><a class="text-secondary" href="https://segmentfault.com/a/1190000039073805#"><span class="mainLike-comment "><i class="fa-w-16 far fa-thumbs-up" style="width: 1em;"></i></span></a><span class="split-dot"></span><a class="text-secondary btn-comment" href="https://segmentfault.com/a/1190000039073805#">回复</a><span class="split-dot"></span><span class="text-secondary">2 月 7 日</span></div><div class="control-area d-none"></div></div></div><div class="replies "><div class="bg-light border-0 mt-2 card"><div class="p-3 card-body"><div class="reply-list list-group"><div class="p-0 border-0 commentUnit false   list-group-item"><div class="font-size-14 mb-1"><a class="d-uname" href="https://segmentfault.com/u/chaojidaxianyu" target="_blank" rel="noreferrer"><strong>超级大咸鱼</strong><span class="text-secondary">（作者）</span></a>：<div class="parsedText fmt"><p>没有</p></div></div><div class="handle-bar font-size-14 d-flex justify-content-between"><div><a class="text-secondary" href="https://segmentfault.com/a/1190000039073805#"><span class="mainLike-comment "><i class="fa-w-16 far fa-thumbs-up" style="width: 1em;"></i></span></a><span class="split-dot"></span><a class="text-secondary btn-reply" href="https://segmentfault.com/a/1190000039073805#">回复</a><span class="split-dot"></span><span class="text-secondary">2 月 22 日</span></div><div class="comment-control-area d-none"></div></div></div></div></div></div></div></div></div></div></div></div></div><div class="recommend-list-wrap mt-4 list-group"><h5 class="h5 mb-2 px-4 px-md-0" style="font-weight: 600;">推荐阅读</h5><div class="card border-0"><div class="list-group list-group-flush"><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000016554033?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">Springboot整合Quartz实现动态定时任务</h5><p class="mb-2 text-truncate text-secondary">Quartz是一款功能强大的任务调度器，可以实现较为复杂的调度功能，如每月一号执行、每天凌晨执行、每周五执行等等，还支持分布式调度。本文使用Springboot+Mybatis+Quartz实现对定时任务的增、删、改、查、启用、...</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">小揪揪</span><span class="split-dot"></span><span>阅读 73.5k</span><span class="split-dot"></span><span>25 赞</span><span class="split-dot"></span><span>10 评论</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000037547548?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">spring-boot-route（二十一）quartz实现动态定时任务</h5><p class="mb-2 text-truncate text-secondary">Quartz是一个定时任务的调度框架，涉及到的主要概念有以下几个：Scheduler：调度器，所有的调度都由它控制，所有的任务都由它管理。Job：任务，定义业务逻辑。JobDetail：基于Job，进一步封装。其中关联一个Job，...</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">Java旅途</span><span class="split-dot"></span><span>阅读 3.1k</span><span class="split-dot"></span><span>8 赞</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000002504252?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">Java 定时任务系列（2）-Spring 定时任务的几种实现</h5><p class="mb-2 text-truncate text-secondary">本文来自网络一些博客的整理（包括gong1208的博客 dary1715的博客） 1、简介 这个系列介绍Spring框架实现定时任务的两种方式以及一些高级的用法，包括： 1、使用Quartz，这是一个功能比较强大的的调度器，可以让...</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">Jacendfeng</span><span class="split-dot"></span><span>阅读 9.8k</span><span class="split-dot"></span><span>5 赞</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000010121349?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">springboot集成quartz2.3.0</h5><p class="mb-2 text-truncate text-secondary">序 quartz是java里头定时任务的经典开源实现，这里讲述一下如何在springboot中集成quartz。 maven {代码...} 内存版配置 {代码...} quartz config {代码...} demo job {代码...} 注册到quartz去调度 {代码...} 使...</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">codecraft</span><span class="split-dot"></span><span>阅读 12.5k</span><span class="split-dot"></span><span>4 赞</span><span class="split-dot"></span><span>15 评论</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000022552084?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">SpringBoot集成Quartz实现定时任务</h5><p class="mb-2 text-truncate text-secondary">在我的前后端分离的实验室管理项目中，有一个功能是学生状态统计。我的设计是按天统计每种状态的比例。为了便于计算，在每天0点，系统需要将学生的状态重置，并插入一条数据作为一天的开始状态。另外，考虑到学生...</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">民意代表</span><span class="split-dot"></span><span>阅读 7.8k</span><span class="split-dot"></span><span>4 赞</span><span class="split-dot"></span><span>2 评论</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000020143783?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">SpringBoot：实现定时任务</h5><p class="mb-2 text-truncate text-secondary">Timer这是java自带的java.util.Timer类，这个类允许你调度一个java.util.TimerTask任务。使用这种方式可以让你的程序按照某一个频度执行，但不能在指定时间运行。一般用的较少。</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">风尘博客</span><span class="split-dot"></span><span>阅读 578</span><span class="split-dot"></span><span>2 赞</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000019153188?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">springboot整合quarzt实现动态定时任务</h5><p class="mb-2 text-truncate text-secondary">我们现在知道了quartz有这么优秀,该怎么整合到项目中呢?笔者接下来将实现一个通过http接口调用来触发动态定时任务的一个小功能.笔者使用的环境:</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">我想问问天</span><span class="split-dot"></span><span>阅读 1.8k</span><span class="split-dot"></span><span>2 赞</span></p></a><a class="list-group-item list-group-item-action py-3" href="https://segmentfault.com/a/1190000019349307?utm_source=sf-related" target="_blank"><h5 class="h5 mb-2 text-break" style="color: rgb(33, 37, 41);">SpringBoot实现动态控制定时任务-支持多参数</h5><p class="mb-2 text-truncate text-secondary">由于工作上的原因，需要进行定时任务的动态增删改查，网上大部分资料都是整合quertz框架实现的。本人查阅了一些资料，发现springBoot本身就支持实现定时任务的动态控制。并进行改进，现支持任意多参数定时任务配置</p><p class="d-flex align-items-center font-size-14 mb-0"><span class="text-primary">连理枝</span><span class="split-dot"></span><span>阅读 2.2k</span><span class="split-dot"></span><span>1 赞</span></p></a></div></div></div></div><div class="col-12 col-xl-auto col"><div class="w-xl-300"><div class="w-xl-300 d-none d-xl-block data-fix" id="author" style="top: 81.2px;"><div class="mb-4 border-0 card"><div class="card-body"><div class="d-flex align-items-center mb-3"><picture class="rounded-circle mr-3"><a href="https://segmentfault.com/u/chaojidaxianyu"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/995577583-600d004f5bef7_big64" alt="avatar" width="64" height="64" class="rounded-circle"></a></picture><div><h5 class="mb-0"><a href="https://segmentfault.com/u/chaojidaxianyu" class="text-body">超级大咸鱼</a></h5></div></div><div class="text-secondary text-truncate-2 userExcerpt mb-3"><p>当学Java的菜鸟</p></div><div class="d-flex align-items-center mb-3"><div class="mr-4"><strong>9</strong><span class="text-secondary"> 声望</span></div><div><strong>1</strong><span class="text-secondary"> 粉丝</span></div></div><button type="button" class="btn btn-primary btn-block">关注作者</button></div></div></div><div class="w-xl-300 mb-4 data-fix" id="first-ad" style="top: 343.2px;"><div class="card border-0 overflow-hidden d-none d-xl-flex justify-content-center align-items-center float-ads"><div id="OA_holder_1" class="ad-container" style="display:block"><div style="line-height: 0"><script async="" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/f(2).txt"></script>
<!-- 文章详情 - 侧栏矩形 -->
<ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-6330872677300335" data-ad-slot="6800875204" data-adsbygoogle-status="done"><ins id="aswift_1_expand" style="display:inline-table;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_1_anchor" style="display:block;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px;background-color:transparent;"><iframe id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;border:0;width:300px;height:250px;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="300" height="250" frameborder="0" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/ads(1).html" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!2" __idm_frm__="260" data-google-query-id="CPWa2vqixe8CFYoLvQodJKsAzw" data-load-complete="true"></iframe></ins></ins></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script><div id="beacon_744af1bcef" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(4).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div></div>
</div></div></div><div id="gridAd" class="d-none d-xl-block mb-4"><div class="border-0 card"><div class="bg-white border-0 card-header"><h5 class="mb-0">宣传栏</h5></div><div class="card-body"><div class="mb-3"><div id="OA_holder_7" class="ad-container" style="display:block"><a href="https://sponsor.segmentfault.com/ck.php?oaparams=2__bannerid=401__zoneid=7__cb=e16cd2e8b2__oadest=https%3A%2F%2Fke.sifou.com%2Fcourse%2F1650000037474720%3Futm_source%3Dsegmentfault%26utm_medium%3Dbanner_Tlink" target="_blank"><strong>专家带你构建一个高性能秒杀系统</strong><br>
<small style="color: #6c757d">大厂电商 Java 秒杀系统架构实战</small></a><div id="beacon_e16cd2e8b2" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(5).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div></div><div class="mb-3"><div id="OA_holder_9" class="ad-container" style="display:block"><a href="https://sponsor.segmentfault.com/ck.php?oaparams=2__bannerid=400__zoneid=9__cb=52661a9fee__oadest=https%3A%2F%2Fke.sifou.com%2Fcourse%2F1650000023864436%3Futm_source%3Dsegmentfault%26utm_medium%3Dbanner_Tlink" target="_blank"><strong>自顶向下学 React 源码</strong><br>
<small style="color: #6c757d">从理念到架构到实现到代码，透彻理解 </small></a><div id="beacon_52661a9fee" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(6).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div></div><div><div id="OA_holder_10" class="ad-container" style="display:block"><div id="beacon_73d3f82937" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(7).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div>
</div></div></div></div></div><div id="second-ad" class="d-none d-xl-block data-fix" style="top: 618.2px; margin-top: 0px;"><div id="OA_holder_31" class="ad-container" style="display:block"><div class="rounded overflow-hidden"><a href="https://sponsor.segmentfault.com/ck.php?oaparams=2__bannerid=334__zoneid=31__cb=e9d6ad9b9f__oadest=https%3A%2F%2Fsegmentfault.com%2Fa%2F1190000020336555" target="_blank"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/bb270f7c8f4604f08f8530813cc9e40c.png" width="300" height="100" alt="程序员求职攻略" title="程序员求职攻略" border="0"></a><div id="beacon_e9d6ad9b9f" style="position: absolute; left: 0px; top: 0px; visibility: hidden;"><img src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/lg(8).php" width="0" height="0" alt="" style="width: 0px; height: 0px;"></div></div>
</div></div><div id="cataLog" class="d-none d-xl-block w-xl-300 mt-4" style="top: auto;"><div data-article-nav="true" class="accordion"><div class="border-0 overflow-hidden d-none d-xl-flex card"><div class="card-body"><div><h6 class="nav-header h6 p-0 m-0"><i class="fas fa-play fa-rotate-undefined"></i><span> 目录</span></h6></div><div id="collapseTarget" class="collapse"><nav id="article-nav-list" class="d-flex flex-column font-size-14 ss-container" data-article-nav-list="true"><div class="ss-wrapper"><div class="ss-content"><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-1" href="javascript:;">Springboot整合quartz实现定时任务的动态加载</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-2" href="javascript:;">目录结构</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-3" href="javascript:;">1.数据库</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-4" href="javascript:;">2.导包</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-5" href="javascript:;">3.Springboot启动配置</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-5-1" href="javascript:;">1.数据源的配置</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-5-2" href="javascript:;">2.mybatisPlus的配置</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-5-3" href="javascript:;">3.Spring的配置</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-6" href="javascript:;">4.mybatis层</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-6-4" href="javascript:;">1.创建数据库表对应的实体</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-6-5" href="javascript:;">2.dao接口</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-6-6" href="javascript:;">3.xml文件</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-6-7" href="javascript:;">4.扫描dao接口</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-7" href="javascript:;">5.线程池的创建</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-8" href="javascript:;">6.quartz相关配置</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-8-8" href="javascript:;">1.自动注入工厂创建</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-9" href="javascript:;">2.quartz配置</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-10" href="javascript:;">7.quartz功能的实现</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-10-9" href="javascript:;">1.基本功能</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-10-10" href="javascript:;">2.任务启动自动加载定时任务</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-10-11" href="javascript:;">3.通过远程请求加载定时任务</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-11" href="javascript:;">8.定时任务</a><a class="nav-link text-secondary p-0 my-1 text-truncate" scroll-href="#item-12" href="javascript:;">9.测试</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-12-12" href="javascript:;">1.向数据库插入一条定时任务的配置。</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-12-13" href="javascript:;">2.启动框架</a><a class="nav-link text-secondary py-0 pr-0 my-1 text-truncate" scroll-href="#item-12-14" href="javascript:;">3.通过网络请求</a></div></div><div class="ss-scroll" style="right: 0px;"></div></nav></div></div></div></div></div></div></div></div><div id="fixedTools" class="position-fixed d-none d-xl-flex" style="right:24px;bottom:24px"><button type="button" class="btn btn-light" title="回顶部">▲</button></div></div><footer id="footer" class="bg-white py-5 font-size-14"><div class="container"><div class="row"><dl class="col-4 col-md-2"><dt class="h6">产品</dt><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/questions/hottest?utm_source=sf-footer" target="_blank" rel="noreferrer">热门问答</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blogs/hottest?utm_source=sf-footer" target="_blank" rel="noreferrer">热门专栏</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives?utm_source=sf-footer" target="_blank" rel="noreferrer">热门课程</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/events?utm_source=sf-footer" target="_blank" rel="noreferrer">最新活动</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/groups?utm_source=sf-footer" target="_blank" rel="noreferrer">技术圈</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/groups?tab=jobs&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">酷工作</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/app?utm_source=sf-footer" target="_blank" rel="noreferrer">移动客户端</a></dd></dl><dl class="col-4 col-md-2"><dt class="h6">课程</dt><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives/edu?tag=java&amp;sort=hottest&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">Java 开发课程</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives/edu?tag=php&amp;sort=hottest&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">PHP 开发课程</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives/edu?tag=python&amp;sort=hottest&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">Python 开发课程</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives/edu?category=1&amp;sort=hottest&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">前端开发课程</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/lives/study?category=3&amp;sort=hottest&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">移动开发课程</a></dd></dl><dl class="col-4 col-md-2 "><dt class="h6">资源</dt><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/weekly?utm_source=sf-footer" target="_blank" rel="noreferrer">每周精选</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/users?utm_source=sf-footer" target="_blank" rel="noreferrer">用户排行榜</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/badges?utm_source=sf-footer" target="_blank" rel="noreferrer">徽章</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/faq?utm_source=sf-footer" target="_blank" rel="noreferrer">帮助中心</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/repu?utm_source=sf-footer" target="_blank" rel="noreferrer">声望与权限</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/community?utm_source=sf-footer" target="_blank" rel="noreferrer">社区服务中心</a></dd></dl><dl class="col-4 col-md-2"><dt class="h6">合作</dt><dd class="my-1"><a class="text-secondary" href="https://about.segmentfault.com/?utm_source=sf-footer" target="_blank" rel="noreferrer">关于我们</a></dd><dd class="my-1"><a class="text-secondary" href="https://business.segmentfault.com/ads?utm_source=sf-footer" target="_blank" rel="noreferrer">广告投放</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/groups?tab=jobs&amp;utm_source=sf-footer" target="_blank" rel="noreferrer">职位发布</a></dd><dd class="my-1"><a class="text-secondary" href="https://jinshuju.net/f/HK5r9K?utm_source=sf-footer" target="_blank" rel="noreferrer">讲师招募</a></dd><dd class="my-1"><a class="text-secondary" href="https://about.segmentfault.com/contact.html?utm_source=sf-footer" target="_blank" rel="noreferrer">联系我们</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/link?utm_source=sf-footer" target="_blank" rel="noreferrer">合作伙伴</a></dd></dl><dl class="col-4 col-md-2"><dt class="h6">关注</dt><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blog/segmentfault?utm_source=sf-footer" target="_blank" rel="noreferrer">产品技术日志</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blog/community_admin?utm_source=sf-footer" target="_blank" rel="noreferrer">社区运营日志</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blog/segmentfault_news?utm_source=sf-footer" target="_blank" rel="noreferrer">市场运营日志</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blog/segmentfault_team?utm_source=sf-footer" target="_blank" rel="noreferrer">团队日志</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/blog/interview?utm_source=sf-footer" target="_blank" rel="noreferrer">社区访谈</a></dd></dl><dl class="col-4 col-md-2" id="license"><dt class="h6">条款</dt><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/tos?utm_source=sf-footer" target="_blank" rel="noreferrer">服务条款</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/privacy?utm_source=sf-footer" target="_blank" rel="noreferrer">隐私政策</a></dd><dd class="my-1"><a class="text-secondary" href="https://segmentfault.com/app?utm_source=sf-footer">下载 App</a></dd><dd class="my-1"><div class="weixin-qrcode ml-n1" title="微信公众号"></div></dd></dl></div><hr class="mt-2 mb-4"><div class="row"><div class="col-md-8"><div class="text-secondary"><p class="mb-1">Copyright © 2011-<!-- -->2021<!-- --> SegmentFault. 当前呈现版本 <!-- -->21.03.22</p><p class="mb-1"><a class="text-secondary mr-2" target="_blank" href="http://beian.miit.gov.cn/" rel="nofollow noreferrer">浙ICP备15005796号-2</a><a class="text-secondary mr-2" target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=33010602002000" rel="nofollow noreferrer">浙公网安备33010602002000号</a><span class="text-secondary">ICP 经营许可 浙B2-20201554</span></p><p class="mb-0">杭州堆栈科技有限公司版权所有</p></div></div><div class="col-md-4 text-right"><div class="shareContent"><a class="share_weixin" data-share="weixin" href="https://segmentfault.com/a/1190000039073805#javascript" aria-label="微信"><i class="mr-1 fab fa-weixin"></i></a><a class="share_weibo" data-share="weibo" href="http://weibo.com/segmentfault" target="_blank" rel="noreferrer" aria-label="微博"><i class="fab fa-weibo mr-1"></i></a><a class="share_github" data-share="github" href="https://github.com/SegmentFault" target="_blank" rel="noreferrer" aria-label="github"><i class="mr-1 fab fa-github"></i></a><a class="share_twitter" data-share="twitter" href="https://twitter.com/segment_fault" target="_blank" rel="noreferrer" aria-label="twitter"><i class="mr-1 fab fa-twitter"></i></a></div></div></div></div></footer></div>
	<script>
  window.g_useSSR = true;
  window.g_initialProps = {"router":{"location":{"pathname":"\u002Fa\u002F1190000039073805","search":"","hash":"","query":{},"state":undefined,"key":"mfce0j"},"action":"POP"},"@@dva":0,"action":{"votes":2,"bookmarks":1,"votesState":false,"bookmarkState":false},"article":{"articles":{"rows":[],"size":0,"offset":0,"hasMore":true,"error":false,"loading":false,"isStopLoad":false,"cutLoadNum":1,"isLoadedFirstRecommend":false,"query":""},"currentTab":""},"articleDetail":{"artDetail":{"1190000039073805":{"title":"java - Springboot整合quartz实现定时任务的动态加载_个人文章","keywords":"mysql,java,quartz,springboot","description":"Springboot整合quartz,实现动态定时任务的加载，不需要重启程序，就可以堆定时任务进行添加，停止，删除，重启等一系列操作，通过mysql数据库对定时任务进行配置。","article":{"id":1190000039073805,"title":"Springboot整合quartz实现定时任务的动态加载","cover":null,"tags_list":"1040000000089439,1040000000089449,1040000000131086,1040000002981698","user_id":1030000039073547,"blog_id":0,"excerpt":"Springboot整合quartz,实现动态定时任务的加载，不需要重启程序，就可以堆定时任务进行添加，停止，删除，重启等一系列操作，通过mysql数据库对定时任务进行配置。","parsed_text":"","is_bookmarked":false,"is_liked":false,"created":1611466404,"modified":1611468824,"real_views":381,"real_unique_views":338,"votes":2,"bookmarks":1,"status":0,"origin_url":"","article_type":1,"license":"0","tags":[{"id":1040000000089449,"url":"\u002Ft\u002Fjava","name":"java","icon_url":"https:\u002F\u002Favatar-static.segmentfault.com\u002F868\u002F271\u002F868271510-54cb382abb7a1_small"},{"id":1040000002981698,"url":"\u002Ft\u002Fspringboot","name":"springboot","icon_url":""},{"id":1040000000131086,"url":"\u002Ft\u002Fquartz","name":"quartz","icon_url":""},{"id":1040000000089439,"url":"\u002Ft\u002Fmysql","name":"mysql","icon_url":"https:\u002F\u002Favatar-static.segmentfault.com\u002F949\u002F844\u002F9498447-54cb56e325a72_small"}],"user":{"id":1030000039073547,"name":"超级大咸鱼","avatar_url":"https:\u002F\u002Favatar-static.segmentfault.com\u002F995\u002F577\u002F995577583-600d004f5bef7_big64","url":"\u002Fu\u002Fchaojidaxianyu","rank":9,"rankWord":"9","is_followed":false,"excerpt":"\u003Cp\u003E当学Java的菜鸟\u003C\u002Fp\u003E","followers":1,"articles":3,"user_auth":null},"status_key":"available"},"blog":null,"actions":[],"member_actions":[],"article_types":{"1":"原创","2":"转载","3":"翻译"},"extra":{"reason":null,"operator":null,"operator_time":null},"tag":{"name":"java","url":"\u002Ft\u002Fjava","icon_url":"https:\u002F\u002Favatar-static.segmentfault.com\u002F868\u002F271\u002F868271510-54cb382abb7a1_small"},"isServerLoaded":true}},"alertMsg":{"showAlert":false,"msg":""},"articleRelated":[]},"editor":{"markdownContent":"","syncMarkdown":false,"title":{"value":"","isInvalid":false,"errorMsg":""},"log":{"value":"","isInvalid":false,"errorMsg":""},"draftInfo":{"id":"","status":""}},"global":{"sessionUser":null,"isHiddenHeader":false,"isHiddenFooter":false,"title":"Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否","selectedTags":[],"isShowLogin":false,"beginnerGuideState":{"visible":false,"type":1},"isShowBindMobile":false,"authChannel":"","unactivated":false,"isShowRegister":false,"headOptions":{"keywords":"mysql,java,quartz,springboot","description":"Springboot整合quartz,实现动态定时任务的加载，不需要重启程序，就可以堆定时任务进行添加，停止，删除，重启等一系列操作，通过mysql数据库对定时任务进行配置。"},"notices":[],"sessionInfo":{"key":"8c93381fd39f438c8e0f8162d6d153fa","login":false,"id":null},"singleNotice":"","currentRoute":{"customLayout":false},"letterNum":0,"noticeNum":0,"serverData":{"userAgent":"Mozilla\u002F5.0 (Windows NT 10.0; WOW64) AppleWebKit\u002F537.36 (KHTML, like Gecko) Chrome\u002F70.0.3538.25 Safari\u002F537.36 Core\u002F1.70.3861.400 QQBrowser\u002F10.7.4313.400","Token":undefined},"userStat":{},"newTask":{}},"video":{"videoData":{},"relationVideos":[],"videos":{"rows":[],"limit":0,"offset":0,"hasMore":true},"lives":[]},"home":{"channels":{},"articles":{"rows":[],"size":0,"offset":0,"hasMore":true,"error":false,"loading":false,"isStopLoad":false,"cutLoadNum":1,"isLoadedFirstRecommend":false},"currentTab":"recommendation","notices":{},"events":{},"recommendArticles":{},"hotQuestions":{},"banners":{}},"letterDetail":{"letterData":{"rows":[],"page":1,"size":100,"total_page":0,"hasMore":true},"loading":false,"readAll":false},"inbox":{"list":{"page":1,"count":0,"rows":{"inbox":{},"messages":[]},"total_page":1},"loading":false},"noticeDetail":{"noticeData":{"rows":[],"offset":"","hasMore":true},"loading":false,"readAll":false},"portal":{"pageData":{},"noticeData":[]},"question":{"questionDetail":{},"relateDetail":{}},"questionList":{"questionList":{"page":1,"size":30,"count":0,"total_page":0,"rows":[]},"updateList":{"offset":"","rows":[]},"showLoading":false,"hostData":{},"userRank":{},"notices":{},"loading":false,"followedTags":[]},"loading":{"global":false,"models":{"global":false,"articleDetail":false},"effects":{"global\u002FgetSessionInfo":false,"articleDetail\u002FgetArtDetail":false}}};
	</script>

    <script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/gt.js.下载"></script>
    <script>
      (function () {
        var data = window.g_initialProps["gtagData"] || window["gtagData"];
        var script = document.createElement("script");
        script.src = "https://www.googletagmanager.com/gtag/js?id=UA-918487-8";
        script.async = true;
        script.onload = function () {
          window.dataLayer = window.dataLayer || [];
          window.gtag = function () {
            window.dataLayer.push(arguments);
          };
          window.gtag("js", new Date());
          window.gtag("config", "UA-918487-8");
          data && window.gtag("set", data);
        };
        document.getElementsByTagName("head")[0].appendChild(script);
      })();
    </script>
    <script src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/umi.js.下载"></script>
  


  <div class="is-active ImageView p-4" style="display: none;">
      <div class="ImageView-inner" style="overflow: auto;">
          <img src="https://segmentfault.com/a/1190000039073805" class="ImageView-img" alt="preview" style="max-width: 100%">
      </div>
  </div><ins class="adsbygoogle adsbygoogle-noablate" data-adsbygoogle-status="done" style="display: none !important;"><ins id="aswift_2_expand" style="display:inline-table;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;" tabindex="0" title="Advertisement" aria-label="Advertisement"><ins id="aswift_2_anchor" style="display:block;border:none;height:0px;margin:0;padding:0;position:relative;visibility:visible;width:0px;background-color:transparent;"><iframe id="aswift_2" name="aswift_2" style="left:0;position:absolute;top:0;border:0;width:undefinedpx;height:undefinedpx;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" frameborder="0" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/ads(2).html" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!3" __idm_frm__="261" data-load-complete="true"></iframe></ins></ins></ins><iframe id="google_osd_static_frame_6285118313780" name="google_osd_static_frame" __idm_frm__="262" style="display: none; width: 0px; height: 0px;" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/saved_resource.html"></iframe><div id="qb-sougou-search" style="display: none; opacity: 0; left: 347.663px; top: 9574.6px;"><p>搜索</p><p class="last-btn">复制</p><iframe src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/saved_resource(1).html" __idm_frm__="273"></iframe></div></body><iframe id="google_esf" name="google_esf" src="./Springboot整合quartz实现定时任务的动态加载 - SegmentFault 思否_files/zrt_lookup.html" data-ad-client="ca-pub-6330872677300335" style="display: none;"></iframe></html>